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

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define F first
#define S second

inline int in() {
  int x, y;
  y = scanf("%d", &x);
  return x;
}

const int N = 200002, E = 200002;

vector<int> g[N], cvs;
vector<pair<int, int>> ces;
int up[N], h[N], from[E], to[E];
bool mark[N];

int cecvme(int v, int pare = -1) // With multiple edge
{
  up[v] = h[v];
  mark[v] = true;
  int children = 0;
  for (int e : g[v])
    if (e != pare) {
      int u = to[e] ^ from[e] ^ v;
      if (mark[u])
        up[v] = min(up[v], h[u]);
      else {
        h[u] = h[v] + 1;
        up[v] = min(up[v], cecvme(u, e));
        if (up[u] >= h[v] && pare != -1)
          cvs.push_back(v);
        children++;
      }
    }
  if (pare != -1 && up[v] == h[v])
    ces.push_back({from[pare], v}); // pare
  if (pare == -1 && children > 1)
    cvs.push_back(v);
  return up[v];
}

int cecv(int v, int par) // Without multiple edge
{
  up[v] = h[v];
  mark[v] = true;
  int children = 0;
  for (int u : g[v]) {
    if (mark[u] && u != par)
      up[v] = min(up[v], h[u]);
    if (!mark[u]) {
      h[u] = h[v] + 1;
      up[v] = min(up[v], cecv(u, v));
      if (up[u] >= h[v] && h[v] > 0)
        cvs.push_back(v);
      children++;
    }
  }
  if (h[v] > 0 && up[v] == h[v])
    ces.push_back({par, v});
  if (h[v] == 0 && children > 1)
    cvs.push_back(v);
  return up[v];
}

int main() {
  h[0] = 0;
  int n = in(), m = in();
  for (int i = 0; i < m; i++) {
    int u = in(), v = in();
    g[u].push_back(v);
    g[v].push_back(u);
    from[i] = u;
    to[i] = v;
  }
  cecv(0, -1);
  for (auto &e : ces)
    if (e.first > e.second)
      swap(e.first, e.second);
  sort(ces.begin(), ces.end());
  for (auto e : ces)
    cout << e.first << " " << e.second << endl;
}


Error: 0

Fixed submission:

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define F first
#define S second

inline int in() {
  int x, y;
  y = scanf("%d", &x);
  return x;
}

const int N = 2002, E = 2002;

vector<int> g[N], cvs;
vector<pair<int, int>> ces;
int up[N], h[N], from[E], to[E];
bool mark[N];

int cecvme(int v, int pare = -1) // With multiple edge
{
  up[v] = h[v];
  mark[v] = true;
  int children = 0;
  for (int e : g[v])
    if (e != pare) {
      int u = to[e] ^ from[e] ^ v;
      if (mark[u])
        up[v] = min(up[v], h[u]);
      else {
        h[u] = h[v] + 1;
        up[v] = min(up[v], cecvme(u, e));
        if (up[u] >= h[v] && pare != -1)
          cvs.push_back(v);
        children++;
      }
    }
  if (pare != -1 && up[v] == h[v])
    ces.push_back({from[pare], v}); // pare
  if (pare == -1 && children > 1)
    cvs.push_back(v);
  return up[v];
}

int cecv(int v, int par) // Without multiple edge
{
  up[v] = h[v];
  mark[v] = true;
  int children = 0;
  for (int u : g[v]) {
    if (mark[u] && u != par)
      up[v] = min(up[v], h[u]);
    if (!mark[u]) {
      h[u] = h[v] + 1;
      up[v] = min(up[v], cecv(u, v));
      if (up[u] >= h[v] && h[v] > 0)
        cvs.push_back(v);
      children++;
    }
  }
  if (h[v] > 0 && up[v] == h[v])
    ces.push_back({par, v});
  if (h[v] == 0 && children > 1)
    cvs.push_back(v);
  return up[v];
}

int main() {
  h[0] = 0;
  int n = in(), m = in();
  for (int i = 0; i < m; i++) {
    int u = in(), v = in();
    g[u].push_back(v);
    g[v].push_back(u);
  }
  cecv(0, -1);
  for (auto &e : ces)
    if (e.first > e.second)
      swap(e.first, e.second);
  sort(ces.begin(), ces.end());
  for (auto e : ces)
    cout << e.first << " " << e.second << endl;
}