Problem p02573 (C++) — buggy submission, verdict: Runtime Error

// Bismillah Hir Rehmanir Rahim
// Allah knows best
using namespace std;
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define mini -10000000000000000
#define start                                                                  \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define f(i, a, n) for (i = a; i < n; i++)
#define ll long long
#define pi 3.141592653589793
#define vi vector<int>
#define si set<int>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rr return 0
#define ff first
#define in insert
#define ss second
#define setbits(x) __builtin_popcountll(x)
#define zrbits(x) __builtin_ctzll(x)
#define deb(x) cout << #x << " = " << x << endl
int vis[200001];
ll cc;
vector<ll> v[200001];
void dfs(ll s) {
  vis[s] = 1;
  cc++;
  for (auto a : v[s]) {
    if (!vis[a])
      dfs(a);
  }
}
int main() {
  ll a, n, i, j, k, m, b;
  cin >> n >> m;
  // vector<int>v[n+1];
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  ll cnt = 0;
  ll mx = 0;
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      cc = 0;
      dfs(i);
      cnt++;
      // deb(cc);
      mx = max(mx, cc);
    }
  }
  cout << mx << endl;
  return 0;
}


Error: 0

Fixed submission:

// Bismillah Hir Rehmanir Rahim
// Allah knows best
using namespace std;
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define mini -10000000000000000
#define start                                                                  \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define f(i, a, n) for (i = a; i < n; i++)
#define ll long long
#define pi 3.141592653589793
#define vi vector<int>
#define si set<int>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rr return 0
#define ff first
#define in insert
#define ss second
#define setbits(x) __builtin_popcountll(x)
#define zrbits(x) __builtin_ctzll(x)
#define deb(x) cout << #x << " = " << x << endl
int vis[100000];
ll cc;
vector<int> v[100000];
void dfs(int s) {
  vis[s] = 1;
  cc++;
  for (auto a : v[s]) {
    if (!vis[a])
      dfs(a);
  }
}
int main() {
  int a, n, i, j, k, m, b;
  cin >> n >> m;
  // vector<int>v[n+1];
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int cnt = 0;
  ll mx = 0;
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      cc = 0;
      dfs(i);
      cnt++;
      // deb(cc);
      mx = max(mx, cc);
    }
  }
  cout << mx << endl;
  return 0;
}