| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 98888 | square1001 | Toy Train (IOI17_train) | C++14 | 2099 ms | 1024 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 <algorithm>
using namespace std;
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size(), m = u.size();
vector<vector<int> > g(n);
for(int i = 0; i < m; ++i) {
g[u[i]].push_back(v[i]);
}
vector<int> dp(n, n);
for(int i = 0; i < n * n; ++i) {
vector<int> ndp(n);
for(int j = 0; j < n; ++j) {
if(a[j] == 1) {
ndp[j] = 0;
for(int k : g[j]) {
ndp[j] = max(ndp[j], dp[k]);
}
}
else {
ndp[j] = n;
for(int k : g[j]) {
ndp[j] = min(ndp[j], dp[k] > 0 ? dp[k] - 1 : 0);
}
}
if(r[j] == 1 && ndp[j] > 0) {
ndp[j] = n;
}
}
dp = ndp;
}
vector<int> ans(n);
for(int i = 0; i < n; ++i) {
ans[i] = (dp[i] > 0 ? 1 : 0);
}
return ans;
}
| # | 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... | ||||
