Submission #641113

#TimeUsernameProblemLanguageResultExecution timeMemory
641113ggohToy Train (IOI17_train)C++14
11 / 100
132 ms1236 KiB
#include "train.h" #include<bits/stdc++.h> using namespace std; #define sz(v) ((int)(v).size()) int n,m,ch[5005],is[2]; vector<int>G[5005],T; void f(int p, vector<int> &a) { while(1) { T.clear(); for(int i=0;i<n;i++) { if(ch[i]!=p) { is[0]=is[1]=0; for(auto &k:G[i]) { if(ch[k]==p)is[p]=1; else is[1-p]=1; } if((a[i]==p && is[a[i]]) || (a[i]!=p && !is[a[i]]))T.push_back(i); } } if(!sz(T))break; for(auto &k:T)ch[k]=p; } } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n=sz(a);m=sz(u); vector<int> res(n); for(int i=0;i<m;i++)G[u[i]].push_back(v[i]); for(int i=0;i<n;i++)ch[i]=r[i]; f(1,a); f(0,a); for(int i=0;i<n;i++)res[i]=ch[i]; return res; }
#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...