# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
641666 |
2022-09-17T12:04:10 Z |
piOOE |
Toy Train (IOI17_train) |
C++17 |
|
2000 ms |
1860 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);
auto dfs = [&](auto self, int v) -> void {
used[v] = true;
in_stk[v] = stk.size();
stk.push_back(v);
if (r[v]) {
last.push_back(last.size() - 1);
} 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]) {
self(self, to);
}
if (a[v] ^ a[to] ^ dp[to]) {
dp[v] = true;
}
}
}
stk.pop_back();
last.pop_back();
in_stk[v] = -1;
};
dfs(dfs, root);
ans[root] = dp[root] ^ a[root] ^ 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
581 ms |
1632 KB |
Output is correct |
2 |
Correct |
201 ms |
1236 KB |
Output is correct |
3 |
Correct |
94 ms |
940 KB |
Output is correct |
4 |
Correct |
34 ms |
904 KB |
Output is correct |
5 |
Correct |
18 ms |
820 KB |
Output is correct |
6 |
Correct |
12 ms |
804 KB |
Output is correct |
7 |
Correct |
10 ms |
808 KB |
Output is correct |
8 |
Correct |
10 ms |
724 KB |
Output is correct |
9 |
Correct |
8 ms |
724 KB |
Output is correct |
10 |
Correct |
7 ms |
724 KB |
Output is correct |
11 |
Correct |
9 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 4th token, expected: '0', found: '1' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
438 ms |
1860 KB |
Output is correct |
2 |
Correct |
407 ms |
1752 KB |
Output is correct |
3 |
Correct |
430 ms |
1660 KB |
Output is correct |
4 |
Execution timed out |
2083 ms |
1548 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1425 ms |
1440 KB |
Output is correct |
2 |
Correct |
254 ms |
980 KB |
Output is correct |
3 |
Correct |
614 ms |
1096 KB |
Output is correct |
4 |
Correct |
881 ms |
1060 KB |
Output is correct |
5 |
Correct |
643 ms |
1228 KB |
Output is correct |
6 |
Incorrect |
541 ms |
1108 KB |
3rd lines differ - on the 1524th token, expected: '0', found: '1' |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2084 ms |
1452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
581 ms |
1632 KB |
Output is correct |
2 |
Correct |
201 ms |
1236 KB |
Output is correct |
3 |
Correct |
94 ms |
940 KB |
Output is correct |
4 |
Correct |
34 ms |
904 KB |
Output is correct |
5 |
Correct |
18 ms |
820 KB |
Output is correct |
6 |
Correct |
12 ms |
804 KB |
Output is correct |
7 |
Correct |
10 ms |
808 KB |
Output is correct |
8 |
Correct |
10 ms |
724 KB |
Output is correct |
9 |
Correct |
8 ms |
724 KB |
Output is correct |
10 |
Correct |
7 ms |
724 KB |
Output is correct |
11 |
Correct |
9 ms |
724 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 4th token, expected: '0', found: '1' |
16 |
Halted |
0 ms |
0 KB |
- |