# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1064008 | 2024-08-18T07:48:10 Z | Ignut | Toy Train (IOI17_train) | C++17 | 0 ms | 0 KB |
// Ignut #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5555; int n, m; vector<int> a, r; vector<int> g[N]; bool ans = false; int used[N]; int cntR[N]; int currR = 0; void dfs(int v) { used[v] = 1; cntR[v] = currR; currR += r[v]; for (int to : g[v]) { if (used[to] == 1) { if (cntR[to] != currR) ans = true; } else if (used[to] == 0) { dfs(to); } } used[v] = 2; }