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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)), (X).end())
#define ft cout << "for test" << endl;
#define read(v, a, n)                                                          \\
  for (int i = a; i < n; i++)                                                  \\
    cin >> v[i];
#define print(v)                                                               \\
  for (auto it : v)                                                            \\
    cout << it << ' ';                                                         \\
  cout << endl;
#define PI 2 * acos(0.0)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FIO                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define t_c                                                                    \\
  int test, cs = 1;                                                            \\
  cin >> test;                                                                 \\
  while (test--)
#define rt return true
#define rf return false

///................function.....................///
#define siz(s) (int)(s.size())
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define dbg(a) cout << #a << " = " << a << " ";
///...........knight moves.....................///
/// int dx[] = {+1,+1,-1,-1,+2,+2,-2,-2};
/// int dy[] = {+2,-2,+2,-2,+1,-1,+1,-1};
const int N = 200005;
vb vis(N);
vvi graph(N);
map<pii, bool> mmp;
int cnt;
void dfs(int node) {
  cnt++;
  vis[node] = true;
  for (auto it : graph[node]) {
    if (!vis[it])
      dfs(it);
  }
}
int main() {
  FIO;
  int n, m, i, j;
  cin >> n >> m;
  int a, b;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    if (mmp[mp(a, b)])
      continue;
    mmp[mp(a, b)] = true;
    mmp[mp(b, a)] = true;
    graph[a].pb(b);
    graph[b].pb(a);
  }
  int mx = 0;
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      cnt = 0;
      dfs(i);
    }
    mx = max(cnt, mx);
  }
  cout << mx << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)), (X).end())
#define ft cout << "for test" << endl;
#define read(v, a, n)                                                          \\
  for (int i = a; i < n; i++)                                                  \\
    cin >> v[i];
#define print(v)                                                               \\
  for (auto it : v)                                                            \\
    cout << it << ' ';                                                         \\
  cout << endl;
#define PI 2 * acos(0.0)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FIO                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define t_c                                                                    \\
  int test, cs = 1;                                                            \\
  cin >> test;                                                                 \\
  while (test--)
#define rt return true
#define rf return false

///................function.....................///
#define siz(s) (int)(s.size())
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define dbg(a) cout << #a << " = " << a << " ";
///...........knight moves.....................///
/// int dx[] = {+1,+1,-1,-1,+2,+2,-2,-2};
/// int dy[] = {+2,-2,+2,-2,+1,-1,+1,-1};
const int N = 100005;
vb vis(N);
vvi graph(N);
map<pii, bool> mmp;
int cnt;
void dfs(int node) {
  cnt++;
  vis[node] = true;
  for (auto it : graph[node]) {
    if (!vis[it])
      dfs(it);
  }
}
int main() {
  FIO;
  int n, m, i, j;
  cin >> n >> m;
  int a, b;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    if (a > b)
      swap(a, b);
    if (mmp[mp(a, b)])
      continue;
    mmp[mp(a, b)] = true;
    graph[a].pb(b);
    graph[b].pb(a);
  }
  int mx = 0;
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      cnt = 0;
      dfs(i);
    }
    mx = max(cnt, mx);
  }
  cout << mx << endl;
}