Submission #110616

#TimeUsernameProblemLanguageResultExecution timeMemory
110616MegaOwIerToy Train (IOI17_train)C++14
100 / 100
404 ms1536 KiB
#include<bits/stdc++.h> using namespace std; const int MX=5005,MN=20005; typedef vector<int> Array; int N,M,deg[MX],need[MX]; Array pre[MX],ans; bool flag; void dfs(int u,Array& w) { for(int i:pre[u]) { need[i]--; if(!w[i]&&!need[i])dfs(i,w); } } Array who_wins(Array a,Array r,Array u,Array v) { N=a.size(),M=u.size(); for(int i=0;i<N;i++)ans.push_back(true); for(int i=0;i<M;i++)pre[v[i]].push_back(u[i]),deg[u[i]]++; while(!flag) { flag=1; for(int i=0;i<N;i++)need[i]=(a[i]?1:deg[i]); for(int i=0;i<N;i++)if(r[i]&&ans[i])dfs(i,r); for(int i=0;i<N;i++)if(r[i]&&ans[i]&&need[i]>0) ans[i]=false,flag=false; } for(int i=0;i<N;i++)ans[i]&=(need[i]<=0); return ans; }
#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...