# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
584080 | yanndev | Toy Train (IOI17_train) | C++17 | 6 ms | 1012 KiB |
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 <bits/stdc++.h>
using namespace std;
const int MX = 5042;
vector<int> graph[MX];
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n, m;
n = (int)a.size();
m = (int)u.size();
for (int i = 0; i < MX; i++)
graph[i].clear();
vector<int> ans (n);
bool isChain = true;
for (int i = 0; i < (int)u.size(); i++) {
graph[u[i]].push_back(v[i]);
if (!(u[i] == v[i] || v[i] == u[i] + 1))
isChain = false;
}
isChain = true;
if (isChain) {
for (int i = n - 1; i >= 0; i--) {
bool hasSelf = false;
bool isOk = false;
for (auto& x: graph[i]) {
if (x == i) {
hasSelf = true;
} else {
isOk |= ans[x];
}
}
if (hasSelf) {
if (a[i] == 1) {
if (r[i] == 1)
isOk = true;
} else {
if (r[i] == 0)
isOk = false;
}
}
ans[i] = (int)isOk;
}
return ans;
}
return ans;
}
Compilation message (stderr)
# | 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... |