# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
775925 | 2023-07-07T07:13:24 Z | Amylopectin | Toy Train (IOI17_train) | C++14 | 2000 ms | 1628 KB |
#include "train.h" #include <vector> #include <algorithm> #include <stdio.h> using namespace std; // const int mxn = 20; const int mxn = 1e4 + 10; vector<int> pat[mxn] = {},ans; int batt[mxn] = {},who[mxn] = {},n,u[mxn] = {},res[mxn] = {},nba[mxn] = {}; int re(int cn,int cnba) { int i,j,fn,of = 0; u[cn] = 1; nba[cn] = cnba; cnba += batt[cn]; if(who[cn] == 1) { for(i=0; i<pat[cn].size(); i++) { fn = pat[cn][i]; if(u[fn] == 2) { if(res[fn] == 1) { of = 1; break; } else if(cnba > nba[fn]) { re(fn,cnba); if(res[fn] == 1) { of = 1; break; } } } else if(u[fn] == 1) { if(nba[fn] < cnba) { of = 1; break; } } else { re(fn,cnba); if(res[fn] == 1) { of = 1; break; } } } if(of == 0) { res[cn] = 0; } else { res[cn] = 1; } } else { for(i=0; i<pat[cn].size(); i++) { fn = pat[cn][i]; if(u[fn] == 2) { if(res[fn] == 0) { if(cnba > nba[fn]) { re(fn,cnba); if(res[fn] == 1) { continue; } } of = 1; break; } } else if(u[fn] == 1) { if(nba[fn] == cnba) { of = 1; break; } } else { re(fn,cnba); if(res[fn] == 0) { of = 1; break; } } } if(of == 0) { res[cn] = 1; } else { res[cn] = 0; } } u[cn] = 2; return 0; } std::vector<int> who_wins(std::vector<int> aa, std::vector<int> rr , std::vector<int> uu, std::vector<int> vv) { int i,j,m = uu.size(),cn,cm,fn,fm; n = aa.size(); for(i=0; i<n; i++) { who[i] = aa[i]; batt[i] = rr[i]; } for(i=0 ;i<m; i++) { pat[uu[i]].push_back(vv[i]); } for(i=0; i<n; i++) { for(j=0; j<n; j++) { u[j] = 0; } re(i,0); ans.push_back(res[i]); } return ans; // std::vector<int> res(a.size()); // for(int i = 0; i < (int)res.size(); i++) // res[i] = i % 2; // return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 980 KB | Output is correct |
2 | Correct | 4 ms | 980 KB | Output is correct |
3 | Correct | 4 ms | 980 KB | Output is correct |
4 | Correct | 4 ms | 980 KB | Output is correct |
5 | Correct | 5 ms | 980 KB | Output is correct |
6 | Correct | 4 ms | 980 KB | Output is correct |
7 | Correct | 5 ms | 1040 KB | Output is correct |
8 | Correct | 4 ms | 980 KB | Output is correct |
9 | Correct | 4 ms | 980 KB | Output is correct |
10 | Correct | 4 ms | 980 KB | Output is correct |
11 | Correct | 3 ms | 980 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 468 KB | Output is correct |
2 | Correct | 0 ms | 468 KB | Output is correct |
3 | Correct | 0 ms | 468 KB | Output is correct |
4 | Incorrect | 1 ms | 468 KB | 3rd lines differ - on the 4th token, expected: '0', found: '1' |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 175 ms | 1628 KB | Output is correct |
2 | Correct | 164 ms | 1564 KB | Output is correct |
3 | Correct | 166 ms | 1560 KB | Output is correct |
4 | Correct | 13 ms | 1312 KB | Output is correct |
5 | Correct | 1557 ms | 1288 KB | Output is correct |
6 | Execution timed out | 2063 ms | 1300 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 972 ms | 1280 KB | Output is correct |
2 | Correct | 76 ms | 1176 KB | Output is correct |
3 | Correct | 30 ms | 1268 KB | Output is correct |
4 | Correct | 8 ms | 1232 KB | Output is correct |
5 | Correct | 127 ms | 1264 KB | Output is correct |
6 | Incorrect | 216 ms | 1296 KB | 3rd lines differ - on the 1524th token, expected: '0', found: '1' |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 459 ms | 1300 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 | 4 ms | 980 KB | Output is correct |
2 | Correct | 4 ms | 980 KB | Output is correct |
3 | Correct | 4 ms | 980 KB | Output is correct |
4 | Correct | 4 ms | 980 KB | Output is correct |
5 | Correct | 5 ms | 980 KB | Output is correct |
6 | Correct | 4 ms | 980 KB | Output is correct |
7 | Correct | 5 ms | 1040 KB | Output is correct |
8 | Correct | 4 ms | 980 KB | Output is correct |
9 | Correct | 4 ms | 980 KB | Output is correct |
10 | Correct | 4 ms | 980 KB | Output is correct |
11 | Correct | 3 ms | 980 KB | Output is correct |
12 | Correct | 0 ms | 468 KB | Output is correct |
13 | Correct | 0 ms | 468 KB | Output is correct |
14 | Correct | 0 ms | 468 KB | Output is correct |
15 | Incorrect | 1 ms | 468 KB | 3rd lines differ - on the 4th token, expected: '0', found: '1' |
16 | Halted | 0 ms | 0 KB | - |