#include <bits/stdc++.h>
#include "Anthony.h"
using namespace std;
namespace {
const int N_MAX = 20000;
const int pattern[] = {0, 1, 0, 0, 1, 1};
int N, M, A, B;
int edge_u[N_MAX], edge_v[N_MAX];
vector <int> adj[N_MAX];
int other (int i, int u) {
return (u != edge_v[i] ? edge_v[i] : edge_u[i]);
}
int up_edge[N_MAX];
int color[N_MAX + 1];
void dfs (int u, int chain = -1) {
if ((int) adj[u].size() == 2 && u != 0) {
if (chain == -1) {
chain = 1 - color[up_edge[u]];
} else {
chain++;
}
} else {
chain = -1;
}
for (int i : adj[u]) {
if (i != up_edge[u]) {
int v = other(i, u);
up_edge[v] = i;
color[i] = (chain == -1 ? 1 - color[up_edge[u]] : pattern[chain % 6]);
dfs(v, chain);
}
}
}
void dfs () {
up_edge[0] = N;
color[0] = 0;
dfs(0);
}
}
vector <int> Mark (int _N, int _M, int _A, int _B, vector <int> _U, vector <int> _V) {
N = _N; M = _M; A = _A; B = _B;
assert(M == N - 1);
for (int i = 0; i < M; i++) {
edge_u[i] = _U[i]; edge_v[i] = _V[i];
adj[edge_u[i]].push_back(i);
adj[edge_v[i]].push_back(i);
}
dfs();
vector <int> X(M);
copy(color, color + M, X.begin());
return X;
}
#include <bits/stdc++.h>
#include "Catherine.h"
using namespace std;
namespace {
int A, B;
vector <int> cols;
bool passed_test;
}
void Init (int _A, int _B) {
A = _A; B = _B;
cols.clear();
passed_test = false;
}
int Move (vector <int> cnt_col) {
int now = (cols.empty() == false ? 1 - cols.back() : 0);
if (cnt_col[now] > 0) {
cols.push_back(now);
} else if (cnt_col[1 - now] > 0) {
cols.push_back(1 - now);
} else {
passed_test = true;
cols = {cols.back()};
return -1;
}
int deg = cnt_col[0] + cnt_col[1] + ((int) cols.size() != 1);
if (cnt_col[cols.back()] > 1 && deg > 2) {
if ((int) cols.size() == 1) {
cols.back() = 1 - cols.back();
} else {
passed_test = true;
cols = {cols.back()};
return -1;
}
}
if (passed_test == false && (int) cols.size() == 6) {
passed_test = true;
bool ok = true;
for (int i = 0; i < (int) cols.size(); i++) {
if (cols[i] == 0 && cols[(i + 1) % 6] == 0) {
ok = (cols[(i + 2) % 6] != cols[(i + 3) % 6]);
}
}
if (ok == false) {
cols.pop_back();
cols = {cols.back()};
return -1;
}
}
return cols.back();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
17064 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
28 ms |
15552 KB |
Output is correct |
4 |
Correct |
36 ms |
18436 KB |
Output is correct |
5 |
Incorrect |
32 ms |
18732 KB |
Wrong Answer [6] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
17064 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
28 ms |
15552 KB |
Output is correct |
4 |
Correct |
36 ms |
18436 KB |
Output is correct |
5 |
Incorrect |
32 ms |
18732 KB |
Wrong Answer [6] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
14408 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
23 ms |
13104 KB |
Output is correct |
4 |
Correct |
39 ms |
16156 KB |
Output is correct |
5 |
Incorrect |
39 ms |
16176 KB |
Wrong Answer [6] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
14408 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
23 ms |
13104 KB |
Output is correct |
4 |
Correct |
39 ms |
16156 KB |
Output is correct |
5 |
Incorrect |
39 ms |
16176 KB |
Wrong Answer [6] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1568 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
1 ms |
1568 KB |
Output is correct |
4 |
Correct |
2 ms |
1636 KB |
Output is correct |
5 |
Correct |
2 ms |
1564 KB |
Output is correct |
6 |
Correct |
2 ms |
1568 KB |
Output is correct |
7 |
Correct |
2 ms |
1564 KB |
Output is correct |
8 |
Correct |
2 ms |
1568 KB |
Output is correct |
9 |
Correct |
2 ms |
1568 KB |
Output is correct |
10 |
Correct |
2 ms |
1572 KB |
Output is correct |
11 |
Correct |
2 ms |
1576 KB |
Output is correct |
12 |
Correct |
2 ms |
1564 KB |
Output is correct |
13 |
Correct |
2 ms |
1568 KB |
Output is correct |
14 |
Correct |
2 ms |
1572 KB |
Output is correct |
15 |
Correct |
2 ms |
1564 KB |
Output is correct |
16 |
Correct |
2 ms |
1552 KB |
Output is correct |
17 |
Correct |
2 ms |
1588 KB |
Output is correct |
18 |
Correct |
2 ms |
1580 KB |
Output is correct |
19 |
Correct |
2 ms |
1572 KB |
Output is correct |
20 |
Correct |
2 ms |
1572 KB |
Output is correct |
21 |
Correct |
1 ms |
1580 KB |
Output is correct |
22 |
Correct |
2 ms |
2028 KB |
Output is correct |
23 |
Correct |
2 ms |
1564 KB |
Output is correct |
24 |
Correct |
2 ms |
1568 KB |
Output is correct |
25 |
Correct |
2 ms |
1404 KB |
Output is correct |
26 |
Correct |
1 ms |
1824 KB |
Output is correct |
27 |
Correct |
2 ms |
1572 KB |
Output is correct |
28 |
Correct |
2 ms |
1688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
11792 KB |
Output is correct |
2 |
Correct |
30 ms |
13384 KB |
Output is correct |
3 |
Correct |
1 ms |
1300 KB |
Output is correct |
4 |
Correct |
20 ms |
11700 KB |
Output is correct |
5 |
Correct |
33 ms |
14668 KB |
Output is correct |
6 |
Correct |
33 ms |
14756 KB |
Output is correct |
7 |
Correct |
30 ms |
13864 KB |
Output is correct |
8 |
Correct |
30 ms |
13896 KB |
Output is correct |
9 |
Correct |
32 ms |
14668 KB |
Output is correct |
10 |
Correct |
32 ms |
14636 KB |
Output is correct |
11 |
Correct |
35 ms |
14928 KB |
Output is correct |
12 |
Correct |
41 ms |
14664 KB |
Output is correct |
13 |
Correct |
31 ms |
14772 KB |
Output is correct |
14 |
Correct |
31 ms |
14736 KB |
Output is correct |
15 |
Correct |
36 ms |
14744 KB |
Output is correct |
16 |
Correct |
31 ms |
14596 KB |
Output is correct |
17 |
Correct |
30 ms |
14400 KB |
Output is correct |
18 |
Correct |
28 ms |
14332 KB |
Output is correct |
19 |
Correct |
36 ms |
14356 KB |
Output is correct |
20 |
Correct |
28 ms |
14416 KB |
Output is correct |
21 |
Correct |
34 ms |
14336 KB |
Output is correct |
22 |
Correct |
30 ms |
14352 KB |
Output is correct |
23 |
Correct |
24 ms |
11856 KB |
Output is correct |
24 |
Correct |
24 ms |
12084 KB |
Output is correct |
25 |
Correct |
26 ms |
12372 KB |
Output is correct |
26 |
Correct |
25 ms |
12380 KB |
Output is correct |
27 |
Correct |
31 ms |
13308 KB |
Output is correct |
28 |
Correct |
27 ms |
13448 KB |
Output is correct |
29 |
Correct |
28 ms |
13368 KB |
Output is correct |
30 |
Correct |
27 ms |
13220 KB |
Output is correct |
31 |
Correct |
28 ms |
11968 KB |
Output is correct |
32 |
Correct |
25 ms |
11848 KB |
Output is correct |
33 |
Correct |
25 ms |
12172 KB |
Output is correct |
34 |
Correct |
26 ms |
12616 KB |
Output is correct |
35 |
Correct |
32 ms |
13404 KB |
Output is correct |
36 |
Correct |
28 ms |
13396 KB |
Output is correct |
37 |
Correct |
26 ms |
13392 KB |
Output is correct |
38 |
Correct |
27 ms |
13364 KB |
Output is correct |
39 |
Correct |
27 ms |
13208 KB |
Output is correct |
40 |
Correct |
31 ms |
13400 KB |
Output is correct |
41 |
Correct |
35 ms |
13660 KB |
Output is correct |
42 |
Correct |
30 ms |
13908 KB |
Output is correct |
43 |
Correct |
30 ms |
13668 KB |
Output is correct |
44 |
Correct |
28 ms |
13896 KB |
Output is correct |
45 |
Correct |
27 ms |
13908 KB |
Output is correct |
46 |
Correct |
37 ms |
13704 KB |
Output is correct |
47 |
Correct |
27 ms |
13092 KB |
Output is correct |
48 |
Correct |
29 ms |
13128 KB |
Output is correct |
49 |
Correct |
34 ms |
12948 KB |
Output is correct |
50 |
Correct |
30 ms |
13096 KB |
Output is correct |
51 |
Correct |
25 ms |
12368 KB |
Output is correct |
52 |
Correct |
28 ms |
12548 KB |
Output is correct |
53 |
Correct |
25 ms |
12108 KB |
Output is correct |
54 |
Correct |
25 ms |
12192 KB |
Output is correct |
55 |
Correct |
25 ms |
12232 KB |
Output is correct |
56 |
Correct |
27 ms |
12112 KB |
Output is correct |
57 |
Correct |
25 ms |
12196 KB |
Output is correct |
58 |
Correct |
32 ms |
12372 KB |
Output is correct |
59 |
Correct |
25 ms |
12024 KB |
Output is correct |
60 |
Correct |
26 ms |
12044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
11848 KB |
Output is correct |
2 |
Correct |
27 ms |
13104 KB |
Output is correct |
3 |
Correct |
1 ms |
1376 KB |
Output is correct |
4 |
Correct |
20 ms |
11568 KB |
Output is correct |
5 |
Correct |
31 ms |
14784 KB |
Output is correct |
6 |
Correct |
37 ms |
14748 KB |
Output is correct |
7 |
Correct |
27 ms |
13772 KB |
Output is correct |
8 |
Correct |
26 ms |
13700 KB |
Output is correct |
9 |
Correct |
30 ms |
14680 KB |
Output is correct |
10 |
Correct |
31 ms |
14744 KB |
Output is correct |
11 |
Correct |
32 ms |
14744 KB |
Output is correct |
12 |
Correct |
30 ms |
14676 KB |
Output is correct |
13 |
Correct |
34 ms |
14656 KB |
Output is correct |
14 |
Correct |
31 ms |
14684 KB |
Output is correct |
15 |
Incorrect |
30 ms |
14652 KB |
Wrong Answer [6] |
16 |
Halted |
0 ms |
0 KB |
- |