Submission #67513

#TimeUsernameProblemLanguageResultExecution timeMemory
67513zscoderToy Train (IOI17_train)C++17
100 / 100
549 ms16764 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<ll,ll> ii; #define mp make_pair #define pb push_back #define fi first #define se second vi adj[22222]; vi radj[22222]; std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { std::vector<int> res(a.size(),0); int n=res.size(); for(int i=0;i<u.size();i++) { adj[u[i]].pb(v[i]); radj[v[i]].pb(u[i]); } while(1) { vector<int> deg(n,0); vector<int> visited(n,0); for(int i=0;i<n;i++) deg[i]=adj[i].size(); queue<int> q; for(int i=0;i<n;i++){if(r[i]) q.push(i);} while(!q.empty()) { int u=q.front(); q.pop(); for(int v:radj[u]) { if(a[v]) { if(!visited[v]) { visited[v]=1; if(!r[v]) q.push(v); //or else double count for case 2 } } else { deg[v]--; if(!deg[v]) { if(!visited[v]) { visited[v]=1; if(!r[v]) q.push(v); } } } } } bool edit=0; for(int i=0;i<n;i++){if(r[i]&&!visited[i]) r[i]=0,edit=1;} if(edit) continue; res=visited; break; } return res; }

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:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<u.size();i++)
              ~^~~~~~~~~
#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...