Submission #71025

#TimeUsernameProblemLanguageResultExecution timeMemory
71025funcsrToy Train (IOI17_train)C++17
5 / 100
17 ms6920 KiB
#include "train.h" #include <iostream> #include <vector> #include <queue> #include <set> #include <algorithm> #include <cassert> #define rep(i, n) for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() #define pb push_back #define INF (1LL<<60) #define _1 first #define _2 second using namespace std; typedef pair<int, int> P; int N, M; vector<int> G[100000]; vector<int> who_wins(vector<int> owner, vector<int> color, vector<int> U, vector<int> V) { N = owner.size(), M = U.size(); rep(i, M) G[U[i]].pb(V[i]), assert(V[i] == U[i] || V[i] == U[i]+1); vector<int> win(N); for (int x=N-1; x>=0; x--) { bool loop = false; for (int t : G[x]) if (x == t) loop = true; bool next = false; for (int t : G[x]) if (x != t) next = true; //A if (owner[x] == 1) { if (color[x] && loop) win[x] = 1; else { if (next) win[x] = win[x+1]; else win[x] = 0; } } else { if (!color[x] && loop) win[x] = 0; else { if (next) win[x] = win[x+1]; else win[x] = 1; } } } return win; }
#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...