# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037631 | 12345678 | Toy Train (IOI17_train) | C++17 | 640 ms | 1372 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 <bits/stdc++.h>
using namespace std;
const int nx=20;
int n, R[nx], A[nx];
vector<int> d[nx];
int solve(int u, vector<int> p)
{
int a=0, b=0;
for (auto v:d[u])
{
int in=0;
for (int i=0; i<p.size(); i++) if (p[i]==v) in=1;
if (in)
{
int pw=R[v];
vector<int> tmp=p;
while (tmp.back()!=v) pw=pw||R[tmp.back()], tmp.pop_back();
if (pw) a++;
else b++;
}
else
{
p.push_back(v);
if (solve(v, p)) a++;
else b++;
p.pop_back();
}
}
if (A[u])
{
if (a>0) return 1;
else return 0;
}
else
{
if (b>0) return 0;
else return 1;
}
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
n=a.size();
vector<int> res(n);
for (int i=0; i<n; i++) R[i]=r[i], A[i]=a[i];
for (int i=0; i<u.size(); i++) d[u[i]].push_back(v[i]);
for (int i=0; i<n; i++) res[i]=solve(i, vector<int> {i});
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... |