# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
641663 |
2022-09-17T12:00:42 Z |
piOOE |
Toy Train (IOI17_train) |
C++17 |
|
2000 ms |
1768 KB |
#include <bits/stdc++.h>
#include "train.h"
using namespace std;
using ll = long long;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> A, std::vector<int> B) {
int n = a.size(), m = A.size();
vector<vector<int>> g(n);
for (int i = 0; i < m; ++i) {
g[A[i]].push_back(B[i]);
}
vector<int> ans(n);
for (int root = 0; root < n; ++root) {
vector<bool> dp(n), used(n);
vector<int> stk, last = {-1};
vector<int> in_stk(n, -1);
function<void(int)> dfs = [&](int v) {
used[v] = true;
in_stk[v] = stk.size();
stk.push_back(v);
if (r[v]) {
last.push_back(last.size());
} else {
last.push_back(last.back());
}
for (int to: g[v]) {
if (in_stk[to] != -1) {
if (a[v] ^ (last.back() < in_stk[to])) {
dp[v] = true;
}
} else {
if (!used[to]) {
dfs(to);
}
if (a[v] ^ a[to] ^ dp[to]) {
dp[v] = true;
}
}
}
stk.pop_back();
last.pop_back();
in_stk[v] = -1;
};
dfs(root);
ans[root] = dp[root] ^ a[root] ^ 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
544 ms |
1400 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
300 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
464 ms |
1768 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1372 ms |
1352 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2045 ms |
1492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
544 ms |
1400 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |