# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294382 | 2020-09-08T21:32:41 Z | eohomegrownapps | Toy Train (IOI17_train) | C++14 | 10 ms | 1536 KB |
#include "train.h" #include <bits/stdc++.h> using namespace std; int n,m; vector<vector<int>> adjlist; vector<vector<int>> revadjlist; vector<int> aowns; vector<int> charging; vector<int> used; // 0 - eliminated, 1 - unvisited, 2 - in f vector<int> awins; void genSet(){ vector<int> numconnected(n,0); queue<int> q; for (int i = 0; i<n; i++){ if (used[i]==2){ q.push(i); } } while (q.size()>0){ int f = q.front(); q.pop(); for (int i : revadjlist[f]){ if (used[i]!=1){continue;} numconnected[i]++; if (aowns[i]||((!aowns[i])&&numconnected[i]==adjlist[i].size())){ // i is in s used[i]=2; q.push(i); } } } } bool eliminate(){ for (int i = 0; i<n; i++){ if (used[i]!=0){ used[i]=1; } if (charging[i]){ used[i]=2; } } genSet(); bool ahasall = true; for (int i = 0; i<n; i++){ if (used[i]==1){ used[i]=2; ahasall=false; } else if (used[i]==2){ used[i]=1; } } if (ahasall){ for (int i = 0; i<n; i++){ if (used[i]==1){ awins[i]=1; } } return true; } genSet(); for (int i = 0; i<n; i++){ if (used[i]==2){ awins[i]=0; used[i]=0; } } return false; } std::vector<int> who_wins(std::vector<int> _aowns, std::vector<int> _charging, std::vector<int> u, std::vector<int> v) { aowns=_aowns; charging=_charging; n=aowns.size(); m=u.size(); //cout<<"blah"<<endl; //cout<<n<<endl; adjlist.resize(n); revadjlist.resize(n); for (int i = 0; i<m; i++){ //cout<<u[i]<<' '<<v[i]<<endl; adjlist[u[i]].push_back(v[i]); revadjlist[v[i]].push_back(u[i]); } //cout<<"bleh"<<endl; awins.resize(n); used.resize(n,1); while (!eliminate()){ continue; } return awins; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 1152 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1536 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 1280 KB | 3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 1408 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 | 5 ms | 1152 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |