#include "bits/stdc++.h"
#include "Anthony.h"
using namespace std;
namespace {
const int maxn = 2e4 + 10;
const int t[] = {1, 0, 0, 1, 1, 0};
const int len = 6;
int l[maxn], r[maxn];
int dist[maxn];
vector <int> g[maxn];
int mark[maxn];
void dfs(int x, int par, int idx) {
int child = 0;
for(auto e : g[x]) {
if(e != par) {
child += 1;
}
}
if(child == 1 && idx == -1) {
for(idx = 0; idx < len; idx++) {
if(t[idx] == mark[x]) {
break;
}
}
}
for(auto e : g[x]) {
int i = l[e] ^ r[e] ^ x;
if(e != par) {
if(child == 1) {
mark[e] = t[(idx + 1) % len];
dfs(i, e, (idx + 1) % len);
} else {
mark[e] = mark[par] ^ 1;
dfs(i, e, -1);
}
}
}
}
} // namespace
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V) {
std::vector<int> X(M);
for (int i = 0; i < N; i++) g[i].clear();
for (int i = 0; i < M; ++i) {
l[i] = U[i];
r[i] = V[i];
g[l[i]].push_back(i);
g[r[i]].push_back(i);
}
if(A > 2) {
for(int i = 0; i < N; i++) dist[i] = -1;
queue <int> Q;
Q.push(0);
dist[0] = 0;
while(!Q.empty()) {
int x = Q.front();
Q.pop();
for(int e : g[x]) {
int i = l[e] ^ r[e] ^ x;
if(dist[i] == -1) {
dist[i] = 1 + dist[x];
Q.push(i);
}
}
}
for(int i = 0; i < M; i++) {
if(dist[l[i]] == dist[r[i]]) X[i] = dist[l[i]] % 3;
else X[i] = min(dist[l[i]], dist[r[i]]) % 3;
}
return X;
}
mark[M] = 0;
dfs(0, M, -1);
for(int i = 0; i < M; i++) X[i] = mark[i];
for(int i = 0; i < M; i++) {
// cout << U[i] << ' ' << V[i] << ' ' << X[i] << endl;
}
return X;
}
#include "bits/stdc++.h"
#include "Catherine.h"
using namespace std;
namespace {
const int len = 6;
const int t[len] = {1, 0, 0, 1, 1, 0};
int arr[len];
int idx = -1;
int A, B;
int variable_example = 0;
vector <int> unpack(vector <int> y) {
vector <int> v;
for(int i = 0; i < y.size(); i++) {
while(y[i]--) v.push_back(i);
}
return v;
}
bool check() {
for(int i = 0; i < len; i++) {
bool bad = false;
for(int j = 0; j < len; j++) {
if(t[(i + j) % len] != arr[j]) bad = true;
}
if(not bad) return true;
}
return false;
}
int last = -1;
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(std::vector<int> y) {
if(A > 2) {
for(int i = 0; i < 3; i++) {
if(y[i] > 0 && y[(2 + i) % 3] == 0) return i;
}
}
++variable_example;
vector <int> v = unpack(y);
if(variable_example == 1 && v.size() == 2) {
idx = 1;
arr[idx - 1] = v[0];
arr[idx] = v[1];
return last = v[1];
}
if(idx != -1) {
if(v.size() == 1) {
arr[idx + 1] = v[0];
idx += 1;
if(idx == len - 1) {
idx = -1;
if(check()) return -1;
else return last = v[0];
} else {
return last = v[0];
}
} else {
idx = -1;
if(y[0] == 0 || y[1] == 0) return -1;
else return last = last ^ 1;
}
}
if(v.size() == 1) return last = v[0];
else if(last == -1) {
for(int i = 0; i < y.size(); i++) if(y[i] == 1) return last = i;
}
else return last = last ^ 1;
}
Compilation message
Catherine.cpp: In function 'std::vector<int> {anonymous}::unpack(std::vector<int>)':
Catherine.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < y.size(); i++) {
~~^~~~~~~~~~
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:71:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < y.size(); i++) if(y[i] == 1) return last = i;
~~^~~~~~~~~~
Catherine.cpp:74:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
16312 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
40 ms |
15660 KB |
Output is correct |
4 |
Correct |
63 ms |
17236 KB |
Output is correct |
5 |
Correct |
63 ms |
17100 KB |
Output is correct |
6 |
Correct |
49 ms |
16044 KB |
Output is correct |
7 |
Correct |
50 ms |
16044 KB |
Output is correct |
8 |
Correct |
60 ms |
16856 KB |
Output is correct |
9 |
Correct |
56 ms |
16844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
16312 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
40 ms |
15660 KB |
Output is correct |
4 |
Correct |
63 ms |
17236 KB |
Output is correct |
5 |
Correct |
63 ms |
17100 KB |
Output is correct |
6 |
Correct |
49 ms |
16044 KB |
Output is correct |
7 |
Correct |
50 ms |
16044 KB |
Output is correct |
8 |
Correct |
60 ms |
16856 KB |
Output is correct |
9 |
Correct |
56 ms |
16844 KB |
Output is correct |
10 |
Correct |
45 ms |
14016 KB |
Output is correct |
11 |
Correct |
44 ms |
14072 KB |
Output is correct |
12 |
Correct |
50 ms |
13900 KB |
Output is correct |
13 |
Correct |
48 ms |
13960 KB |
Output is correct |
14 |
Correct |
48 ms |
14384 KB |
Output is correct |
15 |
Correct |
53 ms |
14532 KB |
Output is correct |
16 |
Correct |
58 ms |
16728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
13900 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
39 ms |
13240 KB |
Output is correct |
4 |
Correct |
61 ms |
15312 KB |
Output is correct |
5 |
Correct |
58 ms |
15248 KB |
Output is correct |
6 |
Correct |
47 ms |
13780 KB |
Output is correct |
7 |
Correct |
45 ms |
13876 KB |
Output is correct |
8 |
Correct |
54 ms |
14420 KB |
Output is correct |
9 |
Correct |
53 ms |
14540 KB |
Output is correct |
10 |
Correct |
49 ms |
14292 KB |
Output is correct |
11 |
Correct |
51 ms |
14404 KB |
Output is correct |
12 |
Correct |
49 ms |
14400 KB |
Output is correct |
13 |
Correct |
52 ms |
14284 KB |
Output is correct |
14 |
Correct |
53 ms |
14656 KB |
Output is correct |
15 |
Correct |
54 ms |
14664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
13900 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
39 ms |
13240 KB |
Output is correct |
4 |
Correct |
61 ms |
15312 KB |
Output is correct |
5 |
Correct |
58 ms |
15248 KB |
Output is correct |
6 |
Correct |
47 ms |
13780 KB |
Output is correct |
7 |
Correct |
45 ms |
13876 KB |
Output is correct |
8 |
Correct |
54 ms |
14420 KB |
Output is correct |
9 |
Correct |
53 ms |
14540 KB |
Output is correct |
10 |
Correct |
49 ms |
14292 KB |
Output is correct |
11 |
Correct |
51 ms |
14404 KB |
Output is correct |
12 |
Correct |
49 ms |
14400 KB |
Output is correct |
13 |
Correct |
52 ms |
14284 KB |
Output is correct |
14 |
Correct |
53 ms |
14656 KB |
Output is correct |
15 |
Correct |
54 ms |
14664 KB |
Output is correct |
16 |
Correct |
41 ms |
12352 KB |
Output is correct |
17 |
Correct |
40 ms |
12476 KB |
Output is correct |
18 |
Correct |
43 ms |
12316 KB |
Output is correct |
19 |
Correct |
43 ms |
12184 KB |
Output is correct |
20 |
Correct |
50 ms |
12852 KB |
Output is correct |
21 |
Correct |
47 ms |
12648 KB |
Output is correct |
22 |
Correct |
52 ms |
14928 KB |
Output is correct |
23 |
Correct |
45 ms |
12236 KB |
Output is correct |
24 |
Correct |
43 ms |
12324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1792 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
2 ms |
1792 KB |
Output is correct |
4 |
Correct |
2 ms |
1792 KB |
Output is correct |
5 |
Correct |
2 ms |
1792 KB |
Output is correct |
6 |
Correct |
2 ms |
1792 KB |
Output is correct |
7 |
Correct |
2 ms |
1792 KB |
Output is correct |
8 |
Correct |
2 ms |
1792 KB |
Output is correct |
9 |
Correct |
2 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
1792 KB |
Output is correct |
11 |
Correct |
2 ms |
1792 KB |
Output is correct |
12 |
Correct |
2 ms |
1792 KB |
Output is correct |
13 |
Correct |
2 ms |
1792 KB |
Output is correct |
14 |
Correct |
2 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
1792 KB |
Output is correct |
16 |
Correct |
2 ms |
1792 KB |
Output is correct |
17 |
Correct |
2 ms |
1792 KB |
Output is correct |
18 |
Correct |
2 ms |
1792 KB |
Output is correct |
19 |
Correct |
2 ms |
1792 KB |
Output is correct |
20 |
Correct |
2 ms |
1792 KB |
Output is correct |
21 |
Correct |
2 ms |
1792 KB |
Output is correct |
22 |
Correct |
2 ms |
1792 KB |
Output is correct |
23 |
Correct |
2 ms |
1792 KB |
Output is correct |
24 |
Correct |
2 ms |
1792 KB |
Output is correct |
25 |
Correct |
2 ms |
1792 KB |
Output is correct |
26 |
Correct |
2 ms |
1792 KB |
Output is correct |
27 |
Correct |
2 ms |
1792 KB |
Output is correct |
28 |
Correct |
2 ms |
1792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
11936 KB |
Output is correct |
2 |
Correct |
51 ms |
13012 KB |
Output is correct |
3 |
Correct |
1 ms |
1536 KB |
Output is correct |
4 |
Correct |
36 ms |
11772 KB |
Output is correct |
5 |
Correct |
58 ms |
14904 KB |
Output is correct |
6 |
Correct |
56 ms |
14868 KB |
Output is correct |
7 |
Correct |
46 ms |
14016 KB |
Output is correct |
8 |
Correct |
47 ms |
13828 KB |
Output is correct |
9 |
Correct |
58 ms |
14880 KB |
Output is correct |
10 |
Correct |
58 ms |
14724 KB |
Output is correct |
11 |
Correct |
60 ms |
14904 KB |
Output is correct |
12 |
Correct |
59 ms |
14772 KB |
Output is correct |
13 |
Correct |
56 ms |
14900 KB |
Output is correct |
14 |
Correct |
56 ms |
14676 KB |
Output is correct |
15 |
Correct |
60 ms |
14764 KB |
Output is correct |
16 |
Correct |
57 ms |
14668 KB |
Output is correct |
17 |
Correct |
53 ms |
14532 KB |
Output is correct |
18 |
Correct |
54 ms |
14276 KB |
Output is correct |
19 |
Correct |
54 ms |
14412 KB |
Output is correct |
20 |
Correct |
53 ms |
14528 KB |
Output is correct |
21 |
Correct |
53 ms |
14528 KB |
Output is correct |
22 |
Correct |
56 ms |
14528 KB |
Output is correct |
23 |
Correct |
43 ms |
11944 KB |
Output is correct |
24 |
Correct |
44 ms |
11860 KB |
Output is correct |
25 |
Correct |
44 ms |
12416 KB |
Output is correct |
26 |
Correct |
44 ms |
12416 KB |
Output is correct |
27 |
Correct |
50 ms |
13140 KB |
Output is correct |
28 |
Correct |
51 ms |
13364 KB |
Output is correct |
29 |
Correct |
50 ms |
13140 KB |
Output is correct |
30 |
Correct |
50 ms |
13484 KB |
Output is correct |
31 |
Correct |
44 ms |
12068 KB |
Output is correct |
32 |
Correct |
46 ms |
11860 KB |
Output is correct |
33 |
Correct |
61 ms |
12240 KB |
Output is correct |
34 |
Correct |
45 ms |
12280 KB |
Output is correct |
35 |
Correct |
52 ms |
13004 KB |
Output is correct |
36 |
Correct |
59 ms |
13064 KB |
Output is correct |
37 |
Correct |
50 ms |
12964 KB |
Output is correct |
38 |
Correct |
49 ms |
13012 KB |
Output is correct |
39 |
Correct |
50 ms |
13004 KB |
Output is correct |
40 |
Correct |
51 ms |
13072 KB |
Output is correct |
41 |
Correct |
53 ms |
13652 KB |
Output is correct |
42 |
Correct |
52 ms |
13836 KB |
Output is correct |
43 |
Correct |
52 ms |
13836 KB |
Output is correct |
44 |
Correct |
58 ms |
13776 KB |
Output is correct |
45 |
Correct |
52 ms |
13756 KB |
Output is correct |
46 |
Correct |
53 ms |
13824 KB |
Output is correct |
47 |
Correct |
49 ms |
12916 KB |
Output is correct |
48 |
Correct |
52 ms |
12884 KB |
Output is correct |
49 |
Correct |
47 ms |
12876 KB |
Output is correct |
50 |
Correct |
49 ms |
12888 KB |
Output is correct |
51 |
Correct |
43 ms |
12356 KB |
Output is correct |
52 |
Correct |
44 ms |
12232 KB |
Output is correct |
53 |
Correct |
43 ms |
12360 KB |
Output is correct |
54 |
Correct |
43 ms |
12364 KB |
Output is correct |
55 |
Correct |
43 ms |
12356 KB |
Output is correct |
56 |
Correct |
45 ms |
12360 KB |
Output is correct |
57 |
Correct |
43 ms |
12116 KB |
Output is correct |
58 |
Correct |
43 ms |
12108 KB |
Output is correct |
59 |
Correct |
45 ms |
12364 KB |
Output is correct |
60 |
Correct |
44 ms |
12360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
12028 KB |
Output is correct |
2 |
Correct |
64 ms |
13100 KB |
Output is correct |
3 |
Correct |
1 ms |
1536 KB |
Output is correct |
4 |
Correct |
39 ms |
11784 KB |
Output is correct |
5 |
Correct |
64 ms |
14716 KB |
Output is correct |
6 |
Correct |
61 ms |
14764 KB |
Output is correct |
7 |
Correct |
45 ms |
13780 KB |
Output is correct |
8 |
Correct |
48 ms |
14008 KB |
Output is correct |
9 |
Correct |
55 ms |
14668 KB |
Output is correct |
10 |
Correct |
56 ms |
14896 KB |
Output is correct |
11 |
Correct |
59 ms |
14688 KB |
Output is correct |
12 |
Correct |
69 ms |
14768 KB |
Output is correct |
13 |
Correct |
60 ms |
14760 KB |
Output is correct |
14 |
Correct |
79 ms |
14668 KB |
Output is correct |
15 |
Correct |
65 ms |
14644 KB |
Output is correct |
16 |
Incorrect |
62 ms |
14904 KB |
Wrong Answer [6] |
17 |
Halted |
0 ms |
0 KB |
- |