# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138352 | 2019-07-29T19:42:51 Z | almogwald | Toy Train (IOI17_train) | C++14 | 12 ms | 1656 KB |
#include <utility> #include <algorithm> #include "train.h" #define fori(i,n) for(int i=0;i<n;i++) #define forib(i,n) for(int i=n-1;i>=0;i--) #define maxl 10000000000 typedef long long lol; using namespace std; vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { int n=a.size(); vector<int> res(n,0); vector<vector<int>> cons(n); vector<vector<int>> opcons(n); fori(i,u.size()){ int cur=u[i]; int next=v[i]; cons[cur].push_back(next); opcons[next].push_back(cur); } int cur=0; vector<int>left(n); fori(i,n){ if(r[i]){ cur=i; } if(a[i]==1){ left[i]=1; }else{ left[i]=cons[i].size(); } } vector<int> help; fori(j,opcons[cur].size()){ int curr=opcons[cur][j]; left[curr]--; if(left[curr]==0){ res[curr]=1; if(cur!=curr){ help.push_back(curr); } } } while(help.size()){ int i=help.back(); help.pop_back(); fori(j,opcons[i].size()){ int curr=opcons[i][j]; left[curr]--; if(left[curr]==0){ res[curr]=1; if(cur!=curr){ help.push_back(curr); } } } } if(res[cur]==0){ fori(i,n){ res[i]=0; } } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 1220 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 | 2 ms | 256 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 | 10 ms | 1528 KB | Output is correct |
2 | Correct | 10 ms | 1656 KB | Output is correct |
3 | Correct | 10 ms | 1656 KB | Output is correct |
4 | Correct | 12 ms | 1628 KB | Output is correct |
5 | Correct | 12 ms | 1644 KB | Output is correct |
6 | Incorrect | 11 ms | 1528 KB | 3rd lines differ - on the 47th token, expected: '1', found: '0' |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 1272 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 | 12 ms | 1400 KB | Output is correct |
2 | Correct | 12 ms | 1528 KB | Output is correct |
3 | Correct | 12 ms | 1528 KB | Output is correct |
4 | Correct | 11 ms | 1528 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 6 ms | 1144 KB | Output is correct |
7 | Correct | 8 ms | 1016 KB | Output is correct |
8 | Correct | 8 ms | 1144 KB | Output is correct |
9 | Correct | 7 ms | 1016 KB | Output is correct |
10 | Correct | 4 ms | 508 KB | Output is correct |
11 | Correct | 7 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 1220 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |