이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |