# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289113 | SamAnd | Toy Train (IOI17_train) | C++17 | 24 ms | 25472 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;
#define m_p make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
const int N = 5003;
int n;
vector<int> a, r;
vector<int> g[N];
bool u[N][N];
vector<int> solv1()
{
vector<int> ans(n);
for (int i = n - 1; i >= 0; --i)
{
if (a[i])
{
if (r[i])
{
if (u[i][i])
{
ans[i] = 1;
}
else
{
ans[i] = ans[i + 1];
}
}
else
{
if (u[i][i + 1])
{
ans[i] = ans[i + 1];
}
else
{
ans[i] = 0;
}
}
}
else
{
if (!r[i])
{
if (u[i][i])
{
ans[i] = 0;
}
else
{
ans[i] = ans[i + 1];
}
}
else
{
if (u[i][i + 1])
{
ans[i] = ans[i + 1];
}
else
{
ans[i] = 1;
}
}
}
}
return ans;
}
std::vector<int> who_wins(std::vector<int> A, std::vector<int> R, std::vector<int> U, std::vector<int> V)
{
a = A;
r = R;
n = sz(a);
bool z1 = true;
for (int i = 0; i < sz(U); ++i)
{
int x = U[i];
int y = V[i];
g[x].push_back(y);
u[x][y] = true;
if (x != y && x + 1 != y)
z1 = false;
}
if (z1)
return solv1();
}
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... |