# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
427572 | 2021-06-14T17:21:40 Z | TLP39 | Toy Train (IOI17_train) | C++14 | 240 ms | 1108 KB |
#include "train.h" #include<bits/stdc++.h> using namespace std; int n,m; vector<int> point_to[5003]; int ori_outdeg[5003]={}; int temp_outdeg[5003]; bool loop[5003]; bool temp_loop[5003]; int cou_loop=0,cou_temp_loop; bool getreach() { queue<int> q; int tt; for(int i=0;i<n;i++) temp_outdeg[i]=ori_outdeg[i]; for(int i=0;i<n;i++) temp_loop[i]=false; cou_temp_loop=0; for(int j=0;j<n;j++) { if(!loop[j]) continue; for(int i=0;i<point_to[j].size();i++) { temp_outdeg[point_to[j][i]]--; if(!temp_outdeg[point_to[j][i]]) q.push(point_to[j][i]); } } while(!q.empty()) { tt=q.front(); q.pop(); temp_loop[tt]=true; if(loop[tt]) { cou_temp_loop++; continue; } for(int i=0;i<point_to[tt].size();i++) { temp_outdeg[point_to[tt][i]]--; if(!temp_outdeg[point_to[tt][i]]) q.push(point_to[tt][i]); } } for(int i=0;i<n;i++) loop[i]=min(loop[i],temp_loop[i]); int temp2=cou_loop; cou_loop=cou_temp_loop; return temp2==cou_temp_loop; } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { std::vector<int> res(a.size(),1); n=a.size(); m=u.size(); for(int i=0;i<m;i++) { point_to[v[i]].push_back(u[i]); ori_outdeg[u[i]]++; } for(int i=0;i<n;i++) {loop[i]=r[i]; cou_loop+=r[i];} for(int i=0;i<n;i++) if(a[i]) ori_outdeg[i]=1; while(!getreach()) continue; for(int i=0;i<n;i++) { res[i]=loop[i]; } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 716 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 | 1 ms | 332 KB | 3rd lines differ - on the 4th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 95 ms | 1108 KB | Output is correct |
2 | Correct | 187 ms | 1100 KB | Output is correct |
3 | Correct | 240 ms | 992 KB | Output is correct |
4 | Incorrect | 8 ms | 1100 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 | 7 ms | 952 KB | 3rd lines differ - on the 21st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 996 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 | 6 ms | 716 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |