# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061257 | 2024-08-16T07:34:22 Z | vjudge1 | Toy Train (IOI17_train) | C++17 | 30 ms | 1388 KB |
// #include "train.h" #include<bits/stdc++.h> using namespace std; const int N = 5000 + 10; vector<int> G[N]; bool R[N], seen[N][N]; int n; bool dfs(int v, int s) { seen[v][s] = true; if(R[v]) return 1; bool ok = 0; for(int u : G[v]) { if(seen[u][s]) continue; ok |= dfs(u, s); } return ok; } vector<int> Arezou() { vector<int> w(n); for(int s = 0; s < n; s++) w[s] = dfs(s, s); return w; } vector<int> Borzou() { vector<int> w(n); return w; } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = a.size(); for(int i = 0; i < u.size(); i ++) G[u[i]].push_back(v[i]); for(int i = 0; i < n; i ++) R[i] = r[i]; vector<int> w(n); int c = count(a.begin(), a.end(), 1); //if(c == a.size()) //return Arezou(); //if(c == 0) //return Borzou(); for(int i = 0; i < n; i++) { int s = i; while(true) { // do I have a cycle bool cycle = false; for(int c : G[s]) if(c == s) cycle = true; if(cycle) { if(G[s].size() == 1) { w[i] = r[s]; break; } if(r[s]) { if(a[s] == 1) { w[i] = 1; break; } s++; continue; } if(a[s] == 1) { s++; continue; } else { w[i] = 0; break; } } else { if(G[s].size()) s++; else { w[i] = 0; break; } } } } return w; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 860 KB | Output is correct |
2 | Correct | 2 ms | 860 KB | Output is correct |
3 | Correct | 2 ms | 912 KB | Output is correct |
4 | Correct | 2 ms | 860 KB | Output is correct |
5 | Correct | 2 ms | 860 KB | Output is correct |
6 | Correct | 2 ms | 860 KB | Output is correct |
7 | Correct | 2 ms | 860 KB | Output is correct |
8 | Correct | 2 ms | 832 KB | Output is correct |
9 | Correct | 3 ms | 860 KB | Output is correct |
10 | Correct | 2 ms | 860 KB | Output is correct |
11 | Correct | 2 ms | 964 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 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 | 22 ms | 1116 KB | Output is correct |
2 | Correct | 25 ms | 1388 KB | Output is correct |
3 | Correct | 23 ms | 1368 KB | Output is correct |
4 | Incorrect | 30 ms | 1372 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 | Incorrect | 21 ms | 860 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 | 1112 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 | Correct | 2 ms | 860 KB | Output is correct |
2 | Correct | 2 ms | 860 KB | Output is correct |
3 | Correct | 2 ms | 912 KB | Output is correct |
4 | Correct | 2 ms | 860 KB | Output is correct |
5 | Correct | 2 ms | 860 KB | Output is correct |
6 | Correct | 2 ms | 860 KB | Output is correct |
7 | Correct | 2 ms | 860 KB | Output is correct |
8 | Correct | 2 ms | 832 KB | Output is correct |
9 | Correct | 3 ms | 860 KB | Output is correct |
10 | Correct | 2 ms | 860 KB | Output is correct |
11 | Correct | 2 ms | 964 KB | Output is correct |
12 | Incorrect | 0 ms | 344 KB | 3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 | Halted | 0 ms | 0 KB | - |