Submission #426529

#TimeUsernameProblemLanguageResultExecution timeMemory
426529jeqchoToy Train (IOI17_train)C++17
0 / 100
13 ms2412 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vpi; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define F0R(i,b) FOR(i,0,b) #define ROF(i,a,b) for(int i=(b)-1;i>=(a);--i) #define R0F(i,b) ROF(i,0,b) #define all(x) begin(x),end(x) #define sz(x) int(x.size()) #define pb push_back #define rsz resize #define trav(a,x) for(auto&a :x) #define fi first #define se second int const N=5e3+3; vi to[N]; vi tor[N]; vi r; int n,m; bitset<N> vis; stack<int> s; vi topsort; bitset<N>c; vi a; bitset<N> nxt; vi ans; void dfs(int now) { if(a[now]) { //A if(r[now]) { if(c[now])ans[now]=1; else ans[now]=ans[now+1]; } else { if(nxt[now])ans[now]=ans[now+1]; else ans[now]=0; } } else { if(!r[now]) { if(c[now])ans[now]=0; else ans[now]=ans[now+1]; } else { if(nxt[now])ans[now]=ans[now+1]; else ans[now]=1; } } } vi who_wins(vi a1, vi r1, vi u, vi v) { a=a1; n=sz(a); m=sz(u); r=r1; F0R(i,m) { to[u[i]].pb(v[i]); if(v[i]==u[i]) { c[i]=1; } else { nxt[u[i]]=1; } } ans.rsz(n); R0F(i,n) { dfs(i); } 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...