# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
294389 | 2020-09-08T21:59:52 Z | eohomegrownapps | 장난감 기차 (IOI17_train) | C++14 | 13 ms | 1664 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(bool player){ vector<int> numconnected(n,0); queue<int> q; for (int i = 0; i<n; i++){ if (used[i]==2){ q.push(i); } /*if (used[i]==0){ for (int x : revadjlist[i]){ numconnected[x]++; } }*/ } while (q.size()>0){ int f = q.front(); q.pop(); for (int i : revadjlist[f]){ if (used[i]!=1){continue;} numconnected[i]++; bool stat = (player)?aowns[i]:(!aowns[i]); if (stat||((!stat)&&numconnected[i]==adjlist[i].size())){ // i is in s used[i]=2; q.push(i); } } } /*for (int i : used){ cout<<i<<' '; }cout<<'\n';*/ } bool eliminate(){ for (int i = 0; i<n; i++){ if (used[i]!=0){ used[i]=1; } if (charging[i]){ used[i]=2; } } genSet(true); 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; } } /*for (int i : used){ cout<<i<<' '; }cout<<'\n';*/ if (ahasall){ for (int i = 0; i<n; i++){ if (used[i]==1){ awins[i]=1; } } return true; } genSet(false); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 1280 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1664 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1408 KB | 3rd lines differ - on the 3065th token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 1664 KB | Output is correct |
2 | Correct | 10 ms | 1536 KB | Output is correct |
3 | Correct | 10 ms | 1536 KB | Output is correct |
4 | Correct | 9 ms | 1536 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Incorrect | 5 ms | 1152 KB | 3rd lines differ - on the 3730th token, expected: '0', found: '1' |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 1280 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |