#include "train.h"
#include <bits/stdc++.h>
using namespace std;
using idata = vector<int>;
using bdata = vector<bool>;
using igrid = vector<idata>;
idata controller, charger;
int N, M;
igrid roads;
idata visited; int stage = 1;
bdata status;
bool dfs (int msk) {
int node = msk >> 1;
int type = msk & 1;
if (visited[msk] >= stage) return status[msk];
visited[msk] = stage;
if (charger[node] == 1 && type == 0 && dfs(msk + 1)) {
status[msk] = true;
visited[msk] = stage + 1;
return true;
}
if (type == 1 && visited[msk - 1] == stage) {
status[msk] = true;
visited[msk] = stage + 1;
return true;
}
status[msk] = false;
for (int next : roads[node]) {
int nxt_msk = next * 2 + type;
if (dfs(nxt_msk)) {
status[msk] = true;
visited[msk] = stage + 1;
return true;
}
}
visited[msk] = stage + 1;
return status[msk];
}
idata who_wins(idata _controller, idata _charger, idata u, idata v) {
N = _controller.size(); M = u.size();
controller = _controller;
charger = _charger;
roads.resize(N);
for (int i = 0; i < M; i ++)
roads[u[i]].push_back(v[i]);
visited.resize(2 * N);
status .resize(2 * N);
idata answer(N, false);
for (int i = 0; i < N; i ++) {
answer[i] = dfs(2 * i);
stage += 2;
}
return answer;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
852 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 |
0 ms |
212 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 |
86 ms |
1392 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 |
4 ms |
980 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 |
Incorrect |
6 ms |
1108 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
852 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |