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

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <bitset>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <math.h>
#include <set>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for (int i = 0; i < (int)n; i++)
#define Loop1(i, n) for (int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for (int i = (int)n; i >= 1; i--)
#define bitmanip(m, val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

struct node {
  bool done;
  vi to;
  int id, from;
  int pre, low;
};

class lowlink {
  int ord;

public:
  vector<node> nodes;
  vector<P> bridges;
  set<int> arts; // articulation point
  lowlink(vector<node> A) {
    ord = 0;
    nodes = A;
  }
  void dfs(int a, int root) {
    nodes[a].done = 1;
    nodes[a].pre = nodes[a].low = ord;
    ord++;
    int cnt = 0;
    Loop(i, nodes[a].to.size()) {
      int b = nodes[a].to[i];
      if (b == nodes[a].from)
        continue;
      if (!nodes[b].done) {
        nodes[b].from = a;
        dfs(b, root);
        nodes[a].low = min(nodes[a].low, nodes[b].low);
        if (nodes[a].pre <= nodes[b].low)
          cnt++;
        if (nodes[a].pre < nodes[b].low)
          bridges.push_back({a, b});
      } else {
        nodes[a].low = min(nodes[a].low, nodes[b].pre);
      }
    }
    if (cnt > (a == root ? 1 : 0))
      arts.insert(a);
    return;
  }
  void find_bridges_and_arts() {
    Loop(i, nodes.size()) {
      if (!nodes[i].done)
        dfs(i, i);
    }
    Loop(i, bridges.size()) {
      if (bridges[i].first > bridges[i].second)
        swap(bridges[i].first, bridges[i].second);
    }
    sort(bridges.begin(), bridges.end());
  }
};

int main() {
  int v, e;
  cin >> v >> e;
  vector<node> nodes(v);
  Loop(i, v) nodes[i] = {0, {}, i, -1, -1, -1};
  Loop(i, e) {
    int s, t;
    cin >> s >> t;
    nodes[s].to.push_back(t);
    nodes[t].to.push_back(s);
  }
  lowlink lk(nodes);
  lk.find_bridges_and_arts();
  auto itr = lk.arts.begin();
  Loop(i, lk.arts.size()) {
    cout << *itr << endl;
    itr++;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <bitset>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <math.h>
#include <set>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for (int i = 0; i < (int)n; i++)
#define Loop1(i, n) for (int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for (int i = (int)n; i >= 1; i--)
#define bitmanip(m, val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

vector<int> G[100000];
vector<pair<int, int>> bridge;
vector<int> articulation;
int ord[100000], low[100000];
bool vis[100000];

void dfs(int v, int p, int &k) {
  vis[v] = true;

  ord[v] = k++;
  low[v] = ord[v];

  bool isArticulation = false;
  int ct = 0;

  for (int i = 0; i < G[v].size(); i++) {
    if (!vis[G[v][i]]) {
      ct++;
      dfs(G[v][i], v, k);
      low[v] = min(low[v], low[G[v][i]]);
      if (~p && ord[v] <= low[G[v][i]])
        isArticulation = true;
      if (ord[v] < low[G[v][i]])
        bridge.push_back(make_pair(min(v, G[v][i]), max(v, G[v][i])));
    } else if (G[v][i] != p) {
      low[v] = min(low[v], ord[G[v][i]]);
    }
  }

  if (p == -1 && ct > 1)
    isArticulation = true;
  if (isArticulation)
    articulation.push_back(v);
}

int main() {
  int n, m;

  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    G[--x].push_back(--y);
    G[y].push_back(x);
  }

  int k = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i])
      dfs(i, -1, k);
  }

  sort(bridge.begin(), bridge.end());
  sort(articulation.begin(), articulation.end());

  for (int i = 0; i < articulation.size(); i++)
    printf("%d\\n", articulation[i] + 1);

  return (0);
}