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

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define scan(any)                                                              \\
  for (auto &i : any)                                                          \\
    cin >> i;
#define print(any)                                                             \\
  for (auto i : any)                                                           \\
    cout << i << " ";
#define endl '\\n'
#define pb push_back
#define vll vector<ll>
#define f(i, x, y) for (i = x; i < y; i++)
#define INF LLONG_MAX
#define fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define s(x) sort(x.begin(), x.end())
#define all(v) v.begin(), v.end()
#define p2(n, x) cout << fixed << setprecision(x) << n << endl;
#define pll pair<ll, ll>
#define ff first
#define ss second
#define blt(x) __builtin_popcount(x)
void addedge(vector<ll> adj[], int u, int v) {
  adj[u].pb(v);
  adj[v].pb(u);
}
ll c = 0;
void dfs(vll adj[], ll u, vector<bool> &vis) {
  c++;
  vis[u] = true;
  ll i;
  f(i, 0, (int)adj[u].size()) {
    if (!vis[adj[u][i]]) {
      dfs(adj, adj[u][i], vis);
    }
  }
}
void solve() {
  ll i, j, k, n, m;
  cin >> n >> m;
  vll adj[n];
  map<pll, ll> m2;
  f(i, 0, m) {
    cin >> j >> k;
    j--;
    k--;
    if (!m2[{j, k}] && !m2[{k, j}]) {
      m2[{j, k}]++;
      m2[{k, j}]++;
      addedge(adj, j, k);
    }
  }
  vector<bool> vis(n, false);
  ll mx = -10;
  f(i, 0, n) {
    if (!vis[i]) {
      c = 0;
      dfs(adj, i, vis);
      mx = max(mx, c);
    }
  }
  cout << mx;
}

int main() {

  fast ll t = 1;

  while (t--)
    solve();

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define scan(any)                                                              \\
  for (auto &i : any)                                                          \\
    cin >> i;
#define print(any)                                                             \\
  for (auto i : any)                                                           \\
    cout << i << " ";
#define endl '\\n'
#define pb push_back
#define vll vector<ll>
#define f(i, x, y) for (i = x; i < y; i++)
#define INF LLONG_MAX
#define fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define s(x) sort(x.begin(), x.end())
#define all(v) v.begin(), v.end()
#define p2(n, x) cout << fixed << setprecision(x) << n << endl;
#define pll pair<ll, ll>
#define ff first
#define ss second
#define blt(x) __builtin_popcount(x)
void addedge(vector<ll> adj[], int u, int v) {
  adj[u].pb(v);
  adj[v].pb(u);
}
ll c = 0;
void dfs(vll adj[], ll u, vector<bool> &vis) {
  c++;
  vis[u] = true;
  ll i;
  f(i, 0, (int)adj[u].size()) {
    if (!vis[adj[u][i]]) {
      dfs(adj, adj[u][i], vis);
    }
  }
}
void solve() {
  ll i, j, k, n, m;
  cin >> n >> m;
  vll adj[n];
  vector<vll> v(n + 2, vector<ll>(n + 2, 0));
  f(i, 0, m) {
    cin >> j >> k;
    j--;
    k--;
    if (!v[j][k] && !v[k][j]) {
      v[j][k]++;
      v[k][j]++;
      addedge(adj, j, k);
    }
  }
  vector<bool> vis(n, false);
  ll mx = -10;
  f(i, 0, n) {
    if (!vis[i]) {
      c = 0;
      dfs(adj, i, vis);
      mx = max(mx, c);
    }
  }
  cout << mx;
}

int main() {
  fast ll t = 1;

  while (t--)
    solve();

  return 0;
}