# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
593953 | FatihSolak | Toy Train (IOI17_train) | C++17 | 1266 ms | 24968 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<cstdio>
#include<algorithm>
using namespace std;
int n, m, D[5010], TD[5010], U[5010];
bool edge[5010][5010];
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size();
m = u.size();
int i, j, k;
for(int i = 0;i<m;i++){
edge[u[i]][v[i]] = 1;
}
for (i = 0; i < n; i++) {
if (r[i] == 1)D[i] = 1;
else D[i] = 0;
if (a[i] == 1)TD[i] = 0;
else TD[i] = 1e9;
}
for (i = 0; i < 10003; i++) {
for (j = 0; j < m; j++) {
if (a[u[j]] == 1 && !(a[v[j]] == 0 && r[v[j]] == 0 && edge[v[j]][v[j]])) {
TD[u[j]] = max(TD[u[j]], r[u[j]] + D[v[j]]);
}
else {
TD[u[j]] = min(TD[u[j]], r[u[j]] + D[v[j]]);
}
}
for (j = 0; j < n; j++) {
if (i == 5002)U[j] = TD[j];
D[j] = TD[j];
if (a[j] == 1)TD[j] = 0;
else TD[j] = 1e9;
}
}
vector<int>res(n);
for (j = 0; j < n; j++) {
if (D[j] != U[j])res[j] = 1;
else res[j] = 0;
}
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... |