#include "Anthony.h"
#include <queue>
#include <utility>
#include <vector>
namespace {
using std::vector;
} // namespace
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V) {
vector<vector<int>> G(N);
for (int i = 0; i < M; ++i) {
G[U[i]].push_back(i);
G[V[i]].push_back(i);
}
std::queue<int> que;
vector<int> dist(N, N);
vector<int> colors(N, -1);
dist[0] = 0;
que.push(0);
for (; !que.empty(); ) {
const int u = que.front();
que.pop();
for (const int i : G[u]) {
const int v = U[i] ^ V[i] ^ u;
if (dist[v] > dist[u] + 1) {
dist[v] = dist[u] + 1;
que.push(v);
if (A == 2) {
if (u == 0) {
colors[v] = 0;
} else if (G[u].size() >= 3) {
colors[v] = ("010011"[colors[u]] == '0') ? 1 : 0;
} else {
colors[v] = (colors[u] + 1) % 6;
}
}
}
}
}
vector<int> x(M, -1);
for (int i = 0; i < M; ++i) {
int u = U[i], v = V[i];
if (dist[u] > dist[v]) {
std::swap(u, v);
}
if (A == 2) {
x[i] = "010011"[colors[v]] - '0';
} else {
x[i] = dist[u] % 3;
}
}
return x;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int A, B, e = -1;
bool ok = false;
vector<int> adj;
vector<int> code{0, 1, 0, 0, 1, 1};
bool extendable(vector<int> a) {
for (int i = 0; i < size(code); ++i) {
bool yay = true;
for (int k = 0; k < size(a); ++k) {
if (a[k] != code[(i + k) % size(code)]) {
yay = false;
break;
}
}
if (yay) {
return true;
}
}
return false;
}
}
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(std::vector<int> yy) {
vector<int> y = yy;
if (e != -1) {
y[e] += 1;
}
int deg = accumulate(y.begin(), y.end(), 0);
if (A >= 3) {
int fi = -1, se = -1, cnt = 0;
for (int i = 0; i < A; ++i) {
if (y[i]) {
fi = fi == -1 ? i : fi;
se = i;
cnt += 1;
}
}
if (fi != 0 || se != 2) {
return e = fi;
} else {
return e = se;
}
} else {
if (deg == 2) {
if (ok) {
return e = find(yy.begin(), yy.end(), 1) - yy.begin();
}
int a = -1, b = -1;
for (int i = 0; i < A; ++i) {
if (y[i]) {
a = a == -1 ? i : a;
b = i;
}
}
if (e == -1) {
adj.push_back(a);
adj.push_back(b);
return e = b;
}
int c = a ^ b ^ e;
adj.push_back(c);
if (adj.size() == 5) {
ok = true;
if (extendable(adj)) {
return -1;
}
return c;
} else {
return e = c;
}
} else {
ok = true;
int ans = find(y.begin(), y.end(), 1) - y.begin();
if (ans == e) {
return -1;
} else {
return e = ans;
}
}
assert(false);
}
}
Compilation message
Catherine.cpp: In function 'bool {anonymous}::extendable(std::vector<int>)':
Catherine.cpp:14:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int i = 0; i < size(code); ++i) {
| ~~^~~~~~~~~~~~
Catherine.cpp:17:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for (int k = 0; k < size(a); ++k) {
| ~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
15052 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
32 ms |
14444 KB |
Output is correct |
4 |
Correct |
51 ms |
16148 KB |
Output is correct |
5 |
Correct |
46 ms |
16128 KB |
Output is correct |
6 |
Correct |
39 ms |
14892 KB |
Output is correct |
7 |
Correct |
38 ms |
14824 KB |
Output is correct |
8 |
Correct |
41 ms |
15480 KB |
Output is correct |
9 |
Correct |
41 ms |
15672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
15052 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
32 ms |
14444 KB |
Output is correct |
4 |
Correct |
51 ms |
16148 KB |
Output is correct |
5 |
Correct |
46 ms |
16128 KB |
Output is correct |
6 |
Correct |
39 ms |
14892 KB |
Output is correct |
7 |
Correct |
38 ms |
14824 KB |
Output is correct |
8 |
Correct |
41 ms |
15480 KB |
Output is correct |
9 |
Correct |
41 ms |
15672 KB |
Output is correct |
10 |
Correct |
34 ms |
12888 KB |
Output is correct |
11 |
Correct |
35 ms |
12760 KB |
Output is correct |
12 |
Correct |
32 ms |
12912 KB |
Output is correct |
13 |
Correct |
37 ms |
12748 KB |
Output is correct |
14 |
Correct |
36 ms |
13068 KB |
Output is correct |
15 |
Correct |
40 ms |
13448 KB |
Output is correct |
16 |
Correct |
41 ms |
15696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
12684 KB |
Output is correct |
2 |
Correct |
1 ms |
508 KB |
Output is correct |
3 |
Correct |
41 ms |
12180 KB |
Output is correct |
4 |
Correct |
46 ms |
13928 KB |
Output is correct |
5 |
Correct |
43 ms |
14024 KB |
Output is correct |
6 |
Correct |
36 ms |
12556 KB |
Output is correct |
7 |
Correct |
33 ms |
12688 KB |
Output is correct |
8 |
Correct |
40 ms |
13300 KB |
Output is correct |
9 |
Correct |
40 ms |
13376 KB |
Output is correct |
10 |
Correct |
40 ms |
13044 KB |
Output is correct |
11 |
Correct |
39 ms |
13008 KB |
Output is correct |
12 |
Correct |
39 ms |
13092 KB |
Output is correct |
13 |
Correct |
43 ms |
12944 KB |
Output is correct |
14 |
Correct |
40 ms |
13444 KB |
Output is correct |
15 |
Correct |
40 ms |
13440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
12684 KB |
Output is correct |
2 |
Correct |
1 ms |
508 KB |
Output is correct |
3 |
Correct |
41 ms |
12180 KB |
Output is correct |
4 |
Correct |
46 ms |
13928 KB |
Output is correct |
5 |
Correct |
43 ms |
14024 KB |
Output is correct |
6 |
Correct |
36 ms |
12556 KB |
Output is correct |
7 |
Correct |
33 ms |
12688 KB |
Output is correct |
8 |
Correct |
40 ms |
13300 KB |
Output is correct |
9 |
Correct |
40 ms |
13376 KB |
Output is correct |
10 |
Correct |
40 ms |
13044 KB |
Output is correct |
11 |
Correct |
39 ms |
13008 KB |
Output is correct |
12 |
Correct |
39 ms |
13092 KB |
Output is correct |
13 |
Correct |
43 ms |
12944 KB |
Output is correct |
14 |
Correct |
40 ms |
13444 KB |
Output is correct |
15 |
Correct |
40 ms |
13440 KB |
Output is correct |
16 |
Correct |
30 ms |
10976 KB |
Output is correct |
17 |
Correct |
30 ms |
10924 KB |
Output is correct |
18 |
Correct |
32 ms |
10944 KB |
Output is correct |
19 |
Correct |
33 ms |
10844 KB |
Output is correct |
20 |
Correct |
35 ms |
11576 KB |
Output is correct |
21 |
Correct |
33 ms |
11360 KB |
Output is correct |
22 |
Correct |
40 ms |
13404 KB |
Output is correct |
23 |
Correct |
33 ms |
10944 KB |
Output is correct |
24 |
Correct |
32 ms |
11068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
776 KB |
Output is correct |
2 |
Correct |
1 ms |
516 KB |
Output is correct |
3 |
Correct |
2 ms |
776 KB |
Output is correct |
4 |
Correct |
2 ms |
776 KB |
Output is correct |
5 |
Correct |
2 ms |
768 KB |
Output is correct |
6 |
Correct |
2 ms |
776 KB |
Output is correct |
7 |
Correct |
3 ms |
768 KB |
Output is correct |
8 |
Correct |
2 ms |
780 KB |
Output is correct |
9 |
Correct |
1 ms |
776 KB |
Output is correct |
10 |
Correct |
3 ms |
780 KB |
Output is correct |
11 |
Correct |
2 ms |
776 KB |
Output is correct |
12 |
Correct |
2 ms |
780 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
772 KB |
Output is correct |
15 |
Correct |
2 ms |
776 KB |
Output is correct |
16 |
Correct |
2 ms |
776 KB |
Output is correct |
17 |
Correct |
2 ms |
776 KB |
Output is correct |
18 |
Correct |
2 ms |
768 KB |
Output is correct |
19 |
Correct |
2 ms |
776 KB |
Output is correct |
20 |
Correct |
2 ms |
776 KB |
Output is correct |
21 |
Correct |
2 ms |
776 KB |
Output is correct |
22 |
Correct |
2 ms |
768 KB |
Output is correct |
23 |
Correct |
2 ms |
768 KB |
Output is correct |
24 |
Correct |
2 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
768 KB |
Output is correct |
26 |
Correct |
2 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
764 KB |
Output is correct |
28 |
Correct |
2 ms |
776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
10648 KB |
Output is correct |
2 |
Correct |
44 ms |
11276 KB |
Output is correct |
3 |
Correct |
0 ms |
516 KB |
Output is correct |
4 |
Correct |
31 ms |
10748 KB |
Output is correct |
5 |
Correct |
46 ms |
12032 KB |
Output is correct |
6 |
Correct |
43 ms |
11924 KB |
Output is correct |
7 |
Correct |
34 ms |
11080 KB |
Output is correct |
8 |
Correct |
35 ms |
11088 KB |
Output is correct |
9 |
Correct |
44 ms |
11940 KB |
Output is correct |
10 |
Correct |
41 ms |
11996 KB |
Output is correct |
11 |
Correct |
47 ms |
11944 KB |
Output is correct |
12 |
Correct |
51 ms |
11940 KB |
Output is correct |
13 |
Correct |
41 ms |
11900 KB |
Output is correct |
14 |
Correct |
41 ms |
12116 KB |
Output is correct |
15 |
Correct |
44 ms |
11896 KB |
Output is correct |
16 |
Correct |
41 ms |
12024 KB |
Output is correct |
17 |
Correct |
40 ms |
11700 KB |
Output is correct |
18 |
Correct |
39 ms |
11736 KB |
Output is correct |
19 |
Correct |
40 ms |
11684 KB |
Output is correct |
20 |
Correct |
36 ms |
11652 KB |
Output is correct |
21 |
Correct |
38 ms |
11712 KB |
Output is correct |
22 |
Correct |
44 ms |
11612 KB |
Output is correct |
23 |
Incorrect |
31 ms |
10900 KB |
Wrong Answer [3] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
10808 KB |
Output is correct |
2 |
Correct |
35 ms |
11080 KB |
Output is correct |
3 |
Correct |
0 ms |
508 KB |
Output is correct |
4 |
Correct |
27 ms |
10588 KB |
Output is correct |
5 |
Correct |
45 ms |
11928 KB |
Output is correct |
6 |
Correct |
44 ms |
11940 KB |
Output is correct |
7 |
Correct |
34 ms |
11096 KB |
Output is correct |
8 |
Correct |
35 ms |
11120 KB |
Output is correct |
9 |
Correct |
43 ms |
11988 KB |
Output is correct |
10 |
Correct |
58 ms |
11868 KB |
Output is correct |
11 |
Correct |
44 ms |
12012 KB |
Output is correct |
12 |
Correct |
39 ms |
12056 KB |
Output is correct |
13 |
Correct |
39 ms |
11924 KB |
Output is correct |
14 |
Correct |
40 ms |
11932 KB |
Output is correct |
15 |
Correct |
44 ms |
12012 KB |
Output is correct |
16 |
Correct |
41 ms |
11988 KB |
Output is correct |
17 |
Correct |
37 ms |
11704 KB |
Output is correct |
18 |
Correct |
39 ms |
11612 KB |
Output is correct |
19 |
Correct |
37 ms |
11628 KB |
Output is correct |
20 |
Correct |
39 ms |
11680 KB |
Output is correct |
21 |
Correct |
38 ms |
11704 KB |
Output is correct |
22 |
Correct |
36 ms |
11636 KB |
Output is correct |
23 |
Correct |
30 ms |
10872 KB |
Output is correct |
24 |
Correct |
31 ms |
10876 KB |
Output is correct |
25 |
Correct |
33 ms |
10996 KB |
Output is correct |
26 |
Correct |
34 ms |
10996 KB |
Output is correct |
27 |
Correct |
37 ms |
11336 KB |
Output is correct |
28 |
Correct |
36 ms |
11372 KB |
Output is correct |
29 |
Correct |
36 ms |
11368 KB |
Output is correct |
30 |
Correct |
40 ms |
11360 KB |
Output is correct |
31 |
Correct |
38 ms |
10812 KB |
Output is correct |
32 |
Correct |
31 ms |
10872 KB |
Output is correct |
33 |
Correct |
34 ms |
10908 KB |
Output is correct |
34 |
Correct |
35 ms |
10964 KB |
Output is correct |
35 |
Correct |
44 ms |
11440 KB |
Output is correct |
36 |
Correct |
49 ms |
11280 KB |
Output is correct |
37 |
Correct |
38 ms |
11372 KB |
Output is correct |
38 |
Correct |
38 ms |
11356 KB |
Output is correct |
39 |
Correct |
34 ms |
11376 KB |
Output is correct |
40 |
Correct |
38 ms |
11312 KB |
Output is correct |
41 |
Correct |
39 ms |
11556 KB |
Output is correct |
42 |
Correct |
37 ms |
11584 KB |
Output is correct |
43 |
Correct |
37 ms |
11540 KB |
Output is correct |
44 |
Correct |
41 ms |
11572 KB |
Output is correct |
45 |
Correct |
39 ms |
11632 KB |
Output is correct |
46 |
Correct |
40 ms |
11652 KB |
Output is correct |
47 |
Correct |
40 ms |
11224 KB |
Output is correct |
48 |
Correct |
35 ms |
11236 KB |
Output is correct |
49 |
Correct |
33 ms |
11044 KB |
Output is correct |
50 |
Correct |
35 ms |
11212 KB |
Output is correct |
51 |
Correct |
35 ms |
11016 KB |
Output is correct |
52 |
Correct |
32 ms |
11060 KB |
Output is correct |
53 |
Correct |
31 ms |
11124 KB |
Output is correct |
54 |
Correct |
32 ms |
10996 KB |
Output is correct |
55 |
Correct |
33 ms |
11068 KB |
Output is correct |
56 |
Correct |
34 ms |
11092 KB |
Output is correct |
57 |
Correct |
34 ms |
10940 KB |
Output is correct |
58 |
Correct |
32 ms |
10900 KB |
Output is correct |
59 |
Correct |
32 ms |
11048 KB |
Output is correct |
60 |
Correct |
33 ms |
11076 KB |
Output is correct |