# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203791 | anonymous | Toy Train (IOI17_train) | C++14 | 12 ms | 1528 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 "train.h"
#include<vector>
#include<iostream>
#define MAXN 1005
using namespace std;
int V,E;
bool can1[MAXN], can2[MAXN]; //uncharged forced path, forced path
vector <int> adj[MAXN];
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
vector<int> res;
V = a.size(), E=u.size();
for (int i=0; i<E; i++) {
adj[u[i]].push_back(v[i]);
}
for (int S=0; S<V; S++) {
for (int e=0; e<E; e++) {
if (r[u[e]] || r[v[e]] || a[u[e]]) {continue;}
for (int i=0; i<V; i++) {
can1[i] = can2[i] = 0;
}
can1[u[e]] = true, can2[v[e]] = true;
for (int i=0; i<V; i++) { //phase
for (int cur=0; cur<V; cur++) { //each node
if (a[cur]) { //charged guy
bool all1 = 1, all2 = 1;
for (auto to: adj[cur]) {
if (!can1[to]) {all1=false;}
if (!can2[to]) {all2=false;}
}
if (!r[cur] && all1) {can1[cur]=true;}
if (all2) {can2[cur]=true;}
} else {
bool has1 = 0, has2 = 0;
for (auto to: adj[cur]) {
if (can1[to]) {has1=true;}
if (can2[to]) {has2=true;}
}
if (!r[cur] && has1) {can1[cur]=true;}
if (has2) {can2[cur]=true;}
}
}
}
if (can2[S] && can1[v[e]]) {
res.push_back(0);
break;
}
}
if (res.size() == S) {
res.push_back(1);
}
}
return res;
}
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... |