Submission #581042

#TimeUsernameProblemLanguageResultExecution timeMemory
581042alirezasamimi100Toy Train (IOI17_train)C++17
5 / 100
10 ms1620 KiB
#include "train.h" #include <bits/stdc++.h> #define pb push_back using namespace std; const int N = 5e3 + 10; vector<int> in[N], out[N]; bool f[N], g[N]; void add_edge(int v, int u){ out[v].pb(u); in[u].pb(v); if(u == v + 1) g[v] = 1; else f[v] = 1; } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { int n = a.size(), m = u.size(); vector<int> res(n); for(int i = 0; i < m; i++) add_edge(u[i], v[i]); res[n - 1] = r[n - 1]; for(int i = n - 2; i >= 0; i--){ if(a[i]){ if((f[i] && r[i]) || (g[i] && res[i + 1])) res[i] = 1; else res[i] = 0; }else{ if((f[i] && !r[i]) || (g[i] && !res[i + 1])) res[i] = 0; else res[i] = 1; } } 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...