Submission #1034750

#TimeUsernameProblemLanguageResultExecution timeMemory
1034750ALeonidouToy Train (IOI17_train)C++17
0 / 100
2028 ms2652 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; #define ll int #define sz(x) (ll)x.size() #define endl "\n" #define pb push_back #define F first #define S second typedef vector <ll> vi; typedef pair <ll,ll> ii; typedef vector <ii> vii; #define dbg(x) cout<<#x<<": "<<x<<endl; #define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl; #define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl; void printVct(vi &v){ for (ll i =0; i<sz(v); i++){ cout<<v[i]<<" "; } cout<<endl; } void printVct2D(vector <vi> &adj){ cout<<endl; for (ll i =0; i<sz(adj); i++){ cout<<i<<": "; for (ll j =0; j<sz(adj[i]); j++){ cout<<adj[i][j]<<" "; } cout<<endl; } cout<<endl; } vector <vi> adj; vi r,a,u,v; vi self_cycles; bool dfs(ll u){ if (self_cycles[u]){ if (r[u] && a[u]) return true; if (!r[u] && !a[u]) return false; } if (adj[u].empty()){ return r[u]; } return dfs(adj[u][0]); } vi who_wins(vi A, vi R, vi U, vi V) { r = R, a = A, u = U, v = V;; ll n = sz(a), m = sz(u); adj.assign(n,vi()); self_cycles.assign(n, 0); for(ll i =0; i<m; i++){ if (v[i] == u[i]) self_cycles[v[i]] = 1; else adj[u[i]].pb(v[i]); } vi ans; for (ll i =0; i<n; i++){ ans[i] = dfs(i); } return ans; } /* 7 9 1 1 1 1 1 1 1 0 1 0 0 0 1 0 0 2 0 1 2 3 1 4 4 5 5 3 3 4 3 6 6 6 */
#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...