# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1063489 | 2024-08-17T19:24:32 Z | Zicrus | Toy Train (IOI17_train) | C++17 | 34 ms | 2136 KB |
#include <bits/stdc++.h> #include "train.h" using namespace std; typedef long long ll; ll n; vector<int> a, r, res; vector<vector<ll>> adj, revAdj; vector<bool> vst; bool dfsCyc(ll cur, ll root) { vst[cur] = true; for (auto &e : adj[cur]) { if (e == root) return true; if (vst[e] || r[e]) continue; if (dfsCyc(e, root)) return true; } return false; } void dfsRes(ll cur) { vst[cur] = true; res[cur] = 0; for (auto &e : revAdj[cur]) { if (vst[e]) continue; dfsRes(e); } } vector<int> who_wins(vector<int> A, vector<int> R, vector<int> u, vector<int> v) { n = A.size(); a = A; r = R; res = vector<int>(n, 1); vst = vector<bool>(n); adj = vector<vector<ll>>(n); revAdj = vector<vector<ll>>(n); for (int i = 0; i < u.size(); i++) { adj[u[i]].push_back(v[i]); revAdj[v[i]].push_back(u[i]); } for (int i = 0; i < n; i++) { if (r[i]) continue; if (dfsCyc(i, i)) { vst = vector<bool>(n); dfsRes(i); } } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 1372 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | 3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2136 KB | Output is correct |
2 | Correct | 7 ms | 1884 KB | Output is correct |
3 | Correct | 6 ms | 1884 KB | Output is correct |
4 | Incorrect | 7 ms | 2136 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1628 KB | Output is correct |
2 | Correct | 7 ms | 1628 KB | Output is correct |
3 | Correct | 8 ms | 1880 KB | Output is correct |
4 | Correct | 34 ms | 1884 KB | Output is correct |
5 | Incorrect | 6 ms | 1884 KB | 3rd lines differ - on the 7th token, expected: '0', found: '1' |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 1884 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 1372 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |