This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |