Submission #53198

#TimeUsernameProblemLanguageResultExecution timeMemory
53198WA_TLEToy Train (IOI17_train)C++14
11 / 100
18 ms5604 KiB
#include "train.h" #include<vector> #include<queue> using namespace std; #define pub push_back std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { int i,j,n=a.size(),m=u.size(); vector<vector<int>>go(n); vector<vector<int>>rev(n); //サイクルになりうるのを求める for(i=0;i<m;i++){ go[u[i]].pub(v[i]); rev[v[i]].pub(u[i]); } vector<int>cir(n); queue<int>que; for(i=0;i<n;i++){ if(r[i]){que.push(i);} else if(a[i]){cir[i]=1;} else{cir[i]=go[i].size();} } //cirが0以下ならチャー駅に行ける(勝つとは言ってない) //0より大きいなら即Bの勝ち while(que.size()>0){ int ter=que.front(); que.pop(); for(auto it:rev[ter]){ if(cir[it]==1){que.push(it);} cir[it]--; } } vector<int>bwi(n); for(i=0;i<n;i++){ if(cir[i]>0){que.push(i);} else if(a[i]){bwi[i]=go[i].size();} else{bwi[i]=1;} } while(que.size()>0){ int ter=que.front(); que.pop(); for(auto it:rev[ter]){ if(bwi[it]==1){que.push(it);} bwi[it]--; } } vector<int>ans(n); for(i=0;i<n;i++){if(bwi[i]>0){ans[i]=1;}} return ans; }

Compilation message (stderr)

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:7:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j,n=a.size(),m=u.size();
        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...