# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
243127 | crossing0ver | Toy Train (IOI17_train) | C++17 | 17 ms | 1408 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>
#define vi vector<int>
#define pb push_back
//#include "train.h"
using namespace std;
int n,m;
vi X,Y,good,who,adj[5009];
vi CASE1() {
vi ans(n);
ans[n-1] = good[n-1];
for (int i = n-2; i >= 0; i--) {
bool flag = 0;
for (int j : adj[i]) {
if (j == i && who[i] == good[i]) {
ans[j] = who[i];
flag = 1;
break;
}
if (who[i] && ans[j]) {
ans[i] = flag = 1;
break;
}
if (!who[i] && !ans[j]) {
flag = 1;
break;
}
}
if (flag == 0) ans[i] = !who[i];
}
return ans;
}
vi who_wins(vi a1, vi r, vi st, vi en) {
n = a1.size(), m = st.size();
X = st; Y = en;
for (int i = 0; i < m; i++)
adj[X[i]].pb(Y[i]);
good = r;
who = a1;
bool case1 = 1;
for (int i = 0; i < m; i++) {
if (X[i] != Y[i] && X[i]+1 != Y[i])
case1 = 0;
}
if (case1) return CASE1();
// 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... |