# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1064008 | Ignut | Toy Train (IOI17_train) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// 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;
}