이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#define TEST
#ifndef TEST
#include "train.h"
#endif // TEST
#include <bits/stdc++.h>
using namespace std;
const int len = 5005;
int self[len], nex[len];
vector<int> who_wins(vector<int> own, vector<int> spe, vector<int> A, vector<int> B) {
int n = own.size(), m = A.size();
for (int i = 0; i < m; i++){
int a = A[i], b = B[i];
if (a == b)
self[a] = 1;
else
nex[a] = 1;
}
vector<int> dp(n);
for (int i = n-1; i > 0; i--){
if (own[i] == 1){
dp[i] = 0;
if (self[i] && spe[i])
dp[i] = 1;
else if (nex[i])
dp[i] = dp[i+1];
}
else{
dp[i] = 1;
if (self[i] && !spe[i])
dp[i] = 0;
else if (nex[i])
dp[i] = dp[i+1];
}
}
return dp;
}
#ifdef TEST
int main() {
freopen("in.txt", "r", stdin);
int n, m;
assert(2 == scanf("%d %d", &n, &m));
vector<int> a(n), r(n), u(m), v(m);
for(int i = 0; i < n; i++)
assert(1 == scanf("%d", &a[i]));
for(int i = 0; i < n; i++)
assert(1 == scanf("%d", &r[i]));
for(int i = 0; i < m; i++)
assert(2 == scanf("%d %d", &u[i], &v[i]));
vector<int> res = who_wins(a, r, u, v);
for(int i = 0; i < (int)res.size(); i++)
printf(i ? " %d" : "%d", res[i]);
printf("\n");
return 0;
}
#endif
| # | 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... |