alexjercan/bugnet huggingface dataset:
Problem p02238 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;

int n;
vector<vector<int>> A;
vector<vector<int>> T;
int t = 0;

void dfs(int cur) { // cur????¨????
  // cur ????¨??????????????¨????
  t += 1;
  T[cur][0] = t;
  // ???????¢??????¨??¨???
  // cerr << "visiting " << cur << " " << t << endl;

  for (int dst = 0; dst < n; ++dst) { // ??¨???????????? dst ????????????
    if (A[cur][dst] == 1 &&
        T[dst][0] ==
            -1) { // cur??????dst??????????????????,dst???????¨??????????
      dfs(dst);
    }
  }
  // cur ????¨????????????????????¨????
  t += 1;
  T[cur][1] = t;
  // ??¢??°?????????????????????????????? (?????¢??°)
  return; // ?????\\???
}

int main() {
  cin >> n;
  A = vector<vector<int>>(n, vector<int>(n, 0));
  T = vector<vector<int>>(n, vector<int>(2, -1));
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
    k -= 1;
    int u;
    cin >> u;
    for (int j = 0; j < u; ++j) {
      int v;
      cin >> v;
      v -= 1;
      A[k][v] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (T[i][0] == -1) {
      dfs(i);
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << i + 1 << " " << T[i][0] << " " << T[i][1] << endl;
  }
}

Error: -11

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int n;
vector<vector<int>> A;
vector<vector<int>> T;
int t = 0;

void dfs(int cur) { // cur????¨????
  // cur ????¨??????????????¨????
  t += 1;
  T[cur][0] = t;
  // ???????¢??????¨??¨???
  cerr << "visiting " << cur << " " << t << endl;

  for (int dst = 0; dst < n; ++dst) { // ??¨???????????? dst ????????????
    if (A[cur][dst] == 1 &&
        T[dst][0] ==
            -1) { // cur??????dst??????????????????,dst???????¨??????????
      dfs(dst);
    }
  }
  // cur ????¨????????????????????¨????
  t += 1;
  T[cur][1] = t;
  // ??¢??°?????????????????????????????? (?????¢??°)
  return; // ?????\\???
}

int main() {
  cin >> n;
  vector<vector<int>> A(n, vector<int>(n, 0));
  vector<vector<int>> T(n, vector<int>(2, -1));
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
    k -= 1;
    int u;
    cin >> u;
    for (int j = 0; j < u; ++j) {
      int v;
      cin >> v;
      v -= 1;
      A[k][v] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (T[i][0] == -1) {
      dfs(i);
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << i + 1 << T[i][0] << T[i][1] << endl;
  }
}
Problem p02238 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define Vi vector<int>
#define FOR(i, s, e) for (int i = s; i < e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int N_MAX = 100;

int adj_matrix[N_MAX + 1][N_MAX + 1];

int d[N_MAX + 1];
int f[N_MAX + 1];

int t;
int n;

void dfs_visit(int id) {
  d[id] = ++t;
  FOR(i, 1, n + 1) {
    if (adj_matrix[id][i] && !d[i]) {
      dfs_visit(i);
    }
  }
  f[id] = ++t;
}

void dfs() {
  FOR(i, 1, n + 1) {
    if (!d[i]) {
      dfs_visit(i);
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  int id, k, v;
  FOR(i, 0, n) {
    cin >> id;
    cin >> k;
    FOR(j, 0, k) {
      cin >> v;
      adj_matrix[id][v] = 1;
    }
  }

  dfs();

  FOR(i, 1, n + 1) { cout << i << " " << d[i] << " " << f[i] << endl; }

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define Vi vector<int>
#define FOR(i, s, e) for (int i = s; i < e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int N_MAX = 100;

int adj_matrix[N_MAX + 1][N_MAX + 1];

int d[N_MAX + 1];
int f[N_MAX + 1];

stack<int> route;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  int id, k, v;
  FOR(i, 0, n) {
    cin >> id;
    cin >> k;
    FOR(j, 0, k) {
      cin >> v;
      adj_matrix[id][v] = 1;
    }
  }

  const int TIMELIMIT = 2 * n;

  int cur = 1;
  route.push(0);
  route.push(0);

  FOR(t, 1, TIMELIMIT) {
    if (!d[cur]) {
      d[cur] = t;
      // cout << t << " " << cur << " start" << endl;
    }
    int next = 0;
    FOR(i, 1, n + 1) {
      if (adj_matrix[cur][i] && !d[i]) {
        next = i;
        break;
      }
    }
    if (next == 0) {
      f[cur] = t + 1;
      cur = route.top();
      route.pop();
      // cout << t << " " << cur << " back" << endl;
    } else {
      route.push(cur);
      cur = next;
      // cout << t << " " << cur << " next" << endl;
    }
  }

  FOR(i, 1, n + 1) { cout << i << " " << d[i] << " " << f[i] << endl; }

  return 0;
}
Problem p02238 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define All(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

int N;
int tt = 0;
vector<vector<int>> G;
vector<int> H, d, f;
int itrNum[100001];
stack<int> S;

void dfs(int u) {
  S.push(u);
  H[u] = 0;

  while (!S.empty()) {
    u = S.top(); // ?¨????????????????
    if (d[u] == 0)
      d[u] = ++tt;
    auto itr_v = next(G[u].begin(), itrNum[u]);
    if (itr_v != G[u].end()) {
      itrNum[u]++;
      int v = *itr_v;
      if (H[v] == -1) {
        H[v] = 0;
        S.push(v);
      }
    } else {
      S.pop();
      H[u] = 1;
      f[u] = ++tt;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N;
  G = vector<vector<int>>(N);
  H = vector<int>(N, -1);
  d = vector<int>(N, 0);
  f = vector<int>(N, 0);
  memset(itrNum, 0, sizeof(itrNum));
  REP(i, N) {
    int u, k;
    cin >> u >> k;
    u--;
    REP(j, k) {
      int v;
      cin >> v;
      v--;
      G[u].pb(v);
    }
  }

  REP(i, N) if (H[i] == -1) dfs(i);
  REP(i, N) { cout << i + 1 << " " << d[i] << " " << f[i] << "\\n"; }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define All(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

int N;
int tt = 0;
vector<vector<int>> G;
vector<int> H, d, f;
int itrNum[100001];
stack<int> S;

void dfs(int u) {
  S.push(u);
  H[u] = 0;

  while (!S.empty()) {
    u = S.top(); // ?¨????????????????
    if (d[u] == 0)
      d[u] = ++tt;
    auto itr_v = next(G[u].begin(), itrNum[u]);
    itrNum[u]++;
    if (itr_v != G[u].end()) {
      int v = *itr_v;
      if (H[v] == -1) {
        H[v] = 0;
        S.push(v);
      }
    } else {
      S.pop();
      H[u] = 1;
      f[u] = ++tt;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N;
  G = vector<vector<int>>(N);
  H = vector<int>(N, -1);
  d = vector<int>(N, 0);
  f = vector<int>(N, 0);
  memset(itrNum, 0, sizeof(itrNum));
  REP(i, N) {
    int u, k;
    cin >> u >> k;
    u--;
    REP(j, k) {
      int v;
      cin >> v;
      v--;
      G[u].pb(v);
    }
  }

  REP(i, N) if (H[i] == -1) dfs(0);
  REP(i, N) { cout << i + 1 << " " << d[i] << " " << f[i] << "\\n"; }
  return 0;
}
Problem p02238 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int n, t;
vector<vector<int>> edges(100);
vector<pair<int, int>> ans(100);
vector<bool> vis(100, false);

void dfs(int v) {
  t++;
  vis[v] = true;
  ans[v].first = t;
  for (int i : edges[v])
    if (vis[i] == false)
      dfs(i);
  t++;
  ans[v].second = t;
}

int main() {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    int k;
    cin >> k >> k;
    for (int j = 0; j < k; j++) {
      int to;
      cin >> to;
      edges[i].push_back(to - 1);
    }
  }

  t = 0;
  for (int i = 0; i < n; i++) {
    if (vis[i] == false)
      dfs(i);
  }
  for (int i = 0; i < n; i++) {
    cout << i + 1 << ' ' << ans[i].first << ' ' << ans[i].second << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int n;
vector<vector<int>> edges(100);
int t;
vector<pair<int, int>> ans(100);
vector<bool> vis(100, false);

void dfs(int v) {
  t++;
  vis[v] = true;
  ans[v].first = t;
  for (int i : edges[v])
    if (vis[i] == false)
      dfs(i);
  t++;
  ans[v].second = t;
}

int main() {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    int k;
    cin >> k >> k;
    for (int j = 0; j < k; j++) {
      int to;
      cin >> to;
      edges[i].push_back(to - 1);
    }
  }

  t = 0;
  dfs(0);
  for (int i = 0; i < n; i++) {
    cout << i + 1 << ' ' << ans[i].first << ' ' << ans[i].second << endl;
  }
}
Problem p02238 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#define MAX 101

int n, ni = 1;
int A[MAX][MAX] = {0}, a[MAX] = {0}, b[MAX] = {0};

void serch(int x) {
  int i;

  a[x] = ni++;
  for (i = 1; i <= n; i++) {
    if (a[i] == 0 && A[x][i] == 1)
      serch(i);
  }
  b[x] = ni++;
}

int main() {
  int i, j, k, x, y;

  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &x, &k);
    for (j = 1; j <= k; j++) {
      scanf("%d", &y);
      A[x][y] = 1;
    }
  }

  for (i = 1; i <= n; i++) {
    if (a[i] == 0)
      serch(i);
  }

  for (i = 1; i <= n; i++) {
    printf("%d %d %d\\n", i, a[i], b[i]);
  }

  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

int A[101][101];
int ans[101][3];
int an = 1;

int judge(int i, int j) {
  if (ans[i][j] == 0) {
    ans[i][j] = an;
    an++;
  }
}

int serch(int a[101][101], int ni, int n) {
  int j;

  for (j = 0; j < n; j++) {
    if (A[ni][j] == 1) {
      judge(j, 1);
      serch(A, j, n);
    }
  }
  judge(ni, 2);
}

int main() {
  int i, j, k, n, x, y;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++)
      A[i][j] = 0;
    ans[i][0] = i + 1;
  }

  for (i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    for (j = 0; j < y; j++) {
      scanf("%d", &k);
      A[i][k - 1] = 1;
    }
  }

  for (j = 0; j < n; j++) {
    judge(j, 1);
    for (i = 0; i < n; i++) {
      if (A[j][i] == 1) {
        judge(i, 1);
        serch(A, i, n);
      }
    }
    judge(j, 2);
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) {
      if (j > 0)
        printf(" ");
      printf("%d", ans[i][j]);
    }
    printf("\\n");
  }

  return 0;
}
Problem p02238 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;

int t = 0, k, n;
int gone[100 + 10] = {}, a[100 + 10][100 + 10] = {}, d[200 + 10], f[200 + 10];

void dfs(int cur) {
  if (gone[cur] != 1) {
    t += 1;
    d[cur] = t;
    gone[cur] = 1;
  }
  for (int m = 1; m <= n; m++) {
    if (a[cur][m] == 1) {
      if (gone[m] == 0) {
        dfs(m);
      }
    }
  }
  t += 1;
  f[cur] = t;
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int u, p;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> p;
      a[i][p] = 1;
    }
  }
  for (int q = 1; q <= n; q++) {
    if (gone[q] != 1)
      dfs(q);
  }
  for (int r = 1; r <= n; r++) {
    cout << r << " " << d[r] << " " << f[r] << endl;
  }
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;

int t = 0, k, n;
int gone[100 + 10] = {}, before[100 + 10] = {}, a[100 + 10][100 + 10] = {};

void dfs(int cur) {
  if (gone[cur] != 1) {
    t += 1;
    cerr << "visiting " << cur << " at " << t << endl;
    gone[cur] = 1;
  }
  for (int m = 1; m <= n; m++) {
    if (a[cur][m] == 1) {
      if (gone[m] == 0) {
        dfs(m);
      }
    }
  }
  t += 1;
  cerr << "complete " << cur << " at " << t << endl;
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int u, p;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> p;
      a[i][p] = 1;
    }
  }
  for (int q = 1; q <= n; q++) {
    if (gone[q] != 1)
      dfs(q);
  }
}
Problem p02238 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
typedef long long ll;
#define int ll

int g[105][105], d[105], f[105];
int presenttime = 1, n;
bool is_search[105];

void dfs(int p) {
  d[p] = presenttime++;
  is_search[p] = true; // ??????????????§?????§??????

  for (int i = 0; i < n; i++) {
    if (is_search[i] == false && g[p][i] && p != i)
      dfs(i);
  }
  if (f[p] == 0)
    f[p] = presenttime++;
}

signed main(void) {
  int u, k, v;

  fill(is_search, is_search + n, false);

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int i = 0; i < k; i++) {
      cin >> v;
      g[u - 1][v - 1] = 1;
    }
  }

  int s = 0, i;

  while (1) {
    dfs(s);

    for (i = 0; i < n; i++) {
      if (is_search[i] == false) {
        s = i;
        break;
      }
    }
    if (i == n)
      break;
  }

  for (i = 0; i < n; i++) {
    cout << i + 1 << " " << d[i] << " " << f[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
typedef long long ll;
#define int ll

int g[105][105], d[105], f[105];
int presenttime = 1, n;
bool is_search[105];

void bfs(int p) {
  d[p] = presenttime++;
  is_search[p] = true; // ??????????????§?????§??????

  for (int i = 0; i < n; i++) {
    if (is_search[i] == false && g[p][i] && p != i)
      bfs(i);
  }
  if (f[p] == 0)
    f[p] = presenttime++;
}

signed main(void) {
  int u, k, v;

  fill(is_search, is_search + n, false);

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int i = 0; i < k; i++) {
      cin >> v;
      g[u - 1][v - 1] = 1;
    }
  }

  int s = 0, i;

  while (1) {
    s = 0;
    bfs(s);

    for (i = 0; i < n; i++) {
      if (is_search[i] == false) {
        s = i;
        break;
      }
    }
    if (i == n)
      break;
  }

  for (i = 0; i < n; i++) {
    cout << i + 1 << " " << d[i] << " " << f[i] << endl;
  }
  return 0;
}
Problem p02238 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int timex = 0;

int n;

string *color = new string[n];

int *d = new int[n];

int *f = new int[n];

int c[100][100];

void dfs(int u) {
  color[u] = "glay";
  d[u] = ++timex;

  for (int v = 0; v < n; v++) {
    if (c[u][v] == 1 && color[v] == "white") {
      dfs(v);
    }
  }

  color[u] = "black";
  f[u] = ++timex;
}

int main() {

  cin >> n;

  color = new string[n];

  d = new int[n];

  f = new int[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      c[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      c[i][v - 1] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    color[i] = "white";
  }

  for (int i = 0; i < n; i++) {
    if (color[i] == "white") {
      dfs(i);
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i + 1 << ' ' << d[i] << ' ' << f[i] << endl;
  }

  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int timex = 0;

int n;

string *color = new string[n];

int *d = new int[n];

int *f = new int[n];

int c[100][100];

void dfs(int u) {
  color[u] = "glay";
  d[u] = ++timex;

  for (int v = 0; v < n; v++) {
    if (c[u][v] == 1 && color[v] == "white") {
      dfs(v);
    }
  }

  color[u] = "black";
  f[u] = ++timex;
}

int main() {

  int n;

  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      c[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      c[i][v - 1] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    color[i] = "white";
  }

  dfs(0);

  for (int i = 0; i < n; i++) {
    cout << i + 1 << ' ' << d[i] << ' ' << f[i] << endl;
  }

  return 0;
}
Problem p02238 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <array>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

static const int N = 100;
static const int white = 0;
static const int gray = 1;
static const int black = 2;
int color[N], nt[N];
int mp[N][N];
int n, d[N], f[N], tt;
int next(int r) {

  for (int i = nt[r]; i < n; i++) {
    nt[r] = i + 1;
    if (mp[r][i])
      return i;
  }
  return -1;
}

void dfs_visit(int r) {
  rep(i, n) { nt[i] = 0; }
  stack<int> s;
  s.push(r);
  d[r] = ++tt;
  color[r] = gray;

  while (!s.empty()) {
    int u = s.top();
    int v = next(u);
    if (v != -1) {
      if (color[v] == white) {
        d[v] = ++tt;
        color[v] = gray;
        s.push(v);
      }
    } else {
      f[u] = ++tt;
      color[u] = black;
      s.pop();
    }
  }
}

void dfs() {
  tt = 0;
  rep(i, n) {
    color[i] = white;
    nt[i] = 0;
  }
  rep(i, n) {
    if (color[i] == white) {
      dfs_visit(i);
    }
  }
  rep(i, n) { cout << i + 1 << " " << d[i] << " " << f[i] << endl; }
}

int main() {
  cin >> n;
  rep(i, N) {
    rep(j, N) { mp[i][j] = 0; }
  }
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    a--;
    rep(i, b) {
      int c;
      cin >> c;
      c--;
      mp[a][c] = 1;
    }
  }
  dfs();
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <array>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

static const int N = 100;
static const int white = 0;
static const int gray = 1;
static const int black = 2;
int color[N], nt[N];
int mp[N][N];
int n, d[N], f[N], tt;
int next(int r) {

  for (int i = nt[r]; i < n; i++) {
    nt[r] = i + 1;
    if (mp[r][i])
      return i;
  }
  return -1;
}

void dfs_visit(int r) {
  rep(i, n) { nt[i] = 0; }
  stack<int> s;
  s.push(r);
  d[r] = ++tt;
  color[r] = gray;
  while (!s.empty()) {
    int u = s.top();
    int v = next(u);
    if (u != -1) {
      d[v] = ++tt;
      color[v] = gray;
      s.push(v);
    } else {
      f[u] = ++tt;
      color[u] = black;
      s.pop();
    }
  }
}

void dfs() {
  tt = 0;
  rep(i, n) {
    if (color[i] == white) {
      dfs_visit(i);
    }
  }
  rep(i, n) { cout << i + 1 << " " << d[i] << " " << f[i] << endl; }
}

int main() {
  cin >> n;
  rep(i, N) {
    rep(i, N) { mp[i][n] = 0; }
  }
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    a--;
    rep(i, b) {
      int c;
      cin >> c;
      c--;
      mp[a][c] = 1;
    }
  }
  dfs();
  return 0;
}
Problem p02238 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;

struct StSeq {
  int m_nBgn;
  int m_nEnd;

  StSeq() : m_nBgn(0), m_nEnd(0) {}
};

void fnInput(vector<vector<int>> &rvvnAdjcy, vector<StSeq> &rvoDFSrch) {
  int nMaxSiz;
  cin >> nMaxSiz;

  rvvnAdjcy.resize(nMaxSiz + 1, vector<int>(nMaxSiz + 1, 0));
  for (int i = 0; i < nMaxSiz; ++i) {
    int nx, nSecSiz;
    cin >> nx >> nSecSiz;
    for (int j = 0; j < nSecSiz; ++j) {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
  StSeq oSeq;
  rvoDFSrch.resize(nMaxSiz + 1, oSeq);
}

void fnDepthFirstSearch(const vector<vector<int>> &cnrvvnAdjcy,
                        vector<StSeq> &rvoDFSrch, int nx) {
  static int stnCnt = 0;

  if (rvoDFSrch[nx].m_nBgn)
    return;
  rvoDFSrch[nx].m_nBgn = ++stnCnt;

  for (int ny = 1; ny < cnrvvnAdjcy.size(); ++ny)
    if (cnrvvnAdjcy[nx][ny] == 1 && nx != ny)
      fnDepthFirstSearch(cnrvvnAdjcy, rvoDFSrch, ny);

  rvoDFSrch[nx].m_nEnd = ++stnCnt;
}

void fnResult(const vector<StSeq> &cnrvoDFSrch) {
  for (int i = 1; i < cnrvoDFSrch.size(); ++i)
    cout << i << " " << cnrvoDFSrch[i].m_nBgn << " " << cnrvoDFSrch[i].m_nEnd
         << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;
  vector<StSeq> voDFSrch;

  fnInput(vvnAdjcy, voDFSrch);
  for (int nx = 1; nx < voDFSrch.size(); ++nx)
    fnDepthFirstSearch(vvnAdjcy, voDFSrch, nx);
  fnResult(voDFSrch);

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

struct StSeq {
  int m_nBgn;
  int m_nEnd;

  StSeq() : m_nBgn(0), m_nEnd(0) {}
};

void fnInput(vector<vector<int>> &rvvnAdjcy, vector<StSeq> &rvoDFSrch) {
  int nMaxSiz;
  cin >> nMaxSiz;

  rvvnAdjcy.resize(nMaxSiz + 1, vector<int>(nMaxSiz + 1, 0));
  for (int i = 0; i < nMaxSiz; ++i) {
    int nx, nSecSiz;
    cin >> nx >> nSecSiz;
    for (int j = 0; j < nSecSiz; ++j) {
      int ny;
      cin >> ny;
      rvvnAdjcy[nx][ny] = 1;
    }
  }
  StSeq oSeq;
  rvoDFSrch.resize(nMaxSiz + 1, oSeq);
}

void fnDepthFirstSearch(const vector<vector<int>> &cnrvvnAdjcy,
                        vector<StSeq> &rvoDFSrch, int nx) {
  static int stnCnt = 0;

  if (rvoDFSrch[nx].m_nEnd)
    return;
  rvoDFSrch[nx].m_nBgn = ++stnCnt;

  for (int ny = 1; ny < cnrvvnAdjcy.size(); ++ny)
    if (cnrvvnAdjcy[nx][ny] == 1 && nx != ny)
      fnDepthFirstSearch(cnrvvnAdjcy, rvoDFSrch, ny);

  rvoDFSrch[nx].m_nEnd = ++stnCnt;
}

void fnResult(const vector<StSeq> &cnrvoDFSrch) {
  for (int i = 1; i < cnrvoDFSrch.size(); ++i)
    cout << i << " " << cnrvoDFSrch[i].m_nBgn << " " << cnrvoDFSrch[i].m_nEnd
         << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> vvnAdjcy;
  vector<StSeq> voDFSrch;

  fnInput(vvnAdjcy, voDFSrch);
  for (int nx = 1; nx < voDFSrch.size(); ++nx)
    fnDepthFirstSearch(vvnAdjcy, voDFSrch, nx);
  fnResult(voDFSrch);

  return 0;
}