# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
641670 |
2022-09-17T12:07:51 Z |
piOOE |
Toy Train (IOI17_train) |
C++17 |
|
1721 ms |
1632 KB |
#include <bits/stdc++.h>
#include "train.h"
using namespace std;
using ll = long long;
constexpr int N = 5000;
vector<int> g[N];
bool dp[N];
int used[N], T = 0;
vector<int> stk, last;
int in_stk[N];
vector<int> r, a;
void dfs(int v) {
used[v] = T;
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] != T) {
dfs(to);
}
if (a[v] ^ a[to] ^ dp[to]) {
dp[v] = true;
}
}
}
stk.pop_back();
last.pop_back();
in_stk[v] = -1;
};
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> A, std::vector<int> B) {
::a = a, ::r = r;
int n = a.size(), m = A.size();
for (int i = 0; i < m; ++i) {
g[A[i]].push_back(B[i]);
}
memset(in_stk, -1, sizeof(in_stk));
last = {-1};
vector<int> ans(n);
for (int root = 0; root < n; ++root) {
++T;
memset(dp, 0, sizeof(dp));
dfs(root);
ans[root] = dp[root] ^ a[root] ^ 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
355 ms |
1384 KB |
Output is correct |
2 |
Correct |
119 ms |
1132 KB |
Output is correct |
3 |
Correct |
53 ms |
984 KB |
Output is correct |
4 |
Correct |
18 ms |
928 KB |
Output is correct |
5 |
Correct |
10 ms |
852 KB |
Output is correct |
6 |
Correct |
5 ms |
768 KB |
Output is correct |
7 |
Correct |
5 ms |
852 KB |
Output is correct |
8 |
Correct |
5 ms |
852 KB |
Output is correct |
9 |
Correct |
6 ms |
872 KB |
Output is correct |
10 |
Correct |
4 ms |
852 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Incorrect |
0 ms |
340 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 |
251 ms |
1632 KB |
Output is correct |
2 |
Correct |
253 ms |
1612 KB |
Output is correct |
3 |
Correct |
257 ms |
1496 KB |
Output is correct |
4 |
Correct |
1710 ms |
1484 KB |
Output is correct |
5 |
Correct |
1232 ms |
1536 KB |
Output is correct |
6 |
Correct |
734 ms |
1348 KB |
Output is correct |
7 |
Correct |
638 ms |
1324 KB |
Output is correct |
8 |
Incorrect |
393 ms |
1364 KB |
3rd lines differ - on the 27th token, expected: '1', found: '0' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1133 ms |
1236 KB |
Output is correct |
2 |
Correct |
194 ms |
1060 KB |
Output is correct |
3 |
Correct |
493 ms |
1132 KB |
Output is correct |
4 |
Correct |
713 ms |
1120 KB |
Output is correct |
5 |
Correct |
504 ms |
1148 KB |
Output is correct |
6 |
Incorrect |
396 ms |
1148 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 |
Incorrect |
1721 ms |
1372 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
355 ms |
1384 KB |
Output is correct |
2 |
Correct |
119 ms |
1132 KB |
Output is correct |
3 |
Correct |
53 ms |
984 KB |
Output is correct |
4 |
Correct |
18 ms |
928 KB |
Output is correct |
5 |
Correct |
10 ms |
852 KB |
Output is correct |
6 |
Correct |
5 ms |
768 KB |
Output is correct |
7 |
Correct |
5 ms |
852 KB |
Output is correct |
8 |
Correct |
5 ms |
852 KB |
Output is correct |
9 |
Correct |
6 ms |
872 KB |
Output is correct |
10 |
Correct |
4 ms |
852 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Incorrect |
0 ms |
340 KB |
3rd lines differ - on the 4th token, expected: '0', found: '1' |
16 |
Halted |
0 ms |
0 KB |
- |