#include "Anthony.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
namespace anton {
const int maxn = 1<<17;
vector<int> val, p, pidx, col, god = {0, 0, 1, 0, 1, 1};
vector<array<int, 2>> g[maxn];
void dfs(int v) {
for(auto &[i, idx] : g[v]) if(i != p[v]) {
p[i] = v, pidx[i] = idx;
col[i] = col[v]^1;
dfs(i);
}
//cout << v << " // " << col[v] << '\n';
if(!v || g[v].size() == 2) return;
int u = p[v];
vector<int> l {v};
while(u && g[u].size() == 2) {
l.pb(u);
u = p[u];
}
int b = 0;
while(god[b] != col[v] || god[(b + l.size() - 1)%6] != col[l.back()]) b++;
//cout << v << " /// " << b << endl;
//cout << god[b] << " vs " << col[v] << '\n';
for(int i = 0; i < l.size(); i++) val[pidx[l[i]]] = god[(i+b)%6];
}
}
namespace antOn {
const int maxn = 1<<17;
vector<array<int, 2>> g[maxn];
vector<int> val, lvl;
queue<int> q;
void solve() {
lvl[0] = 0;
q.push(0);
vector<array<int, 3>> edges(val.size());
while(!q.empty()) {
int u = q.front();
q.pop();
for(auto &[i, idx] : g[u]) {
if(lvl[i] == -1) {
lvl[i] = lvl[u] + 1;
q.push(i);
}
edges[idx] = {i, u, idx};
}
}
map<int, map<int, int>> col;
col[1][0] = col[0][1] = 0;
col[2][1] = col[1][2] = 1;
col[0][2] = col[2][0] = 2;
col[0][0] = 0;
col[1][1] = 2;
col[2][2] = 1;
for(auto [u, v, idx] : edges) val[idx] = col[lvl[u]%3][lvl[v]%3];
}
}
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V) {
if(B == 0) {
for(int i = 0; i < M; i++) {
antOn::g[U[i]].pb({V[i], i});
antOn::g[V[i]].pb({U[i], i});
}
antOn::val.resize(M);
antOn::lvl.resize(N, -1);
antOn::solve();
return antOn::val;
}
using namespace anton;
val.resize(M);
for(int i = 0; i < M; i++) {
g[U[i]].pb({V[i], i});
g[V[i]].pb({U[i], i});
}
p.resize(N);
pidx.resize(N);
col.resize(N);
dfs(0);
//for(int i = 0; i < M; i++) cout << U[i] << " " << V[i] << " " << val[i] << '\n';
return val;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
namespace kate {
int A, B, gg = 0, lst = -2, mvs = 0;
string cur, god = "110100110100";
int decide(vector<int> c) {
if(B == 0) {
if(!c[0] && !c[1]) return 2;
if(!c[0] && !c[2]) return 1;
if(!c[1] && !c[2]) return 0;
if(c[0] && c[1]) return 0;
if(c[2] && c[1]) return 1;
if(c[2] && c[0]) return 2;
}
if(mvs++ > 10 && !gg) exit(-1);
if(c[0] + c[1] == 0) {
gg = 1;
return -1;
}
if(lst == -2 && c[0]+c[1] == 1) {
gg = 1;
return lst = c[1];
}
if(c[0] + c[1] + (lst != -2) > 2) {
gg = 1;
if(c[0] == 0) return -1;
if(c[1] == 0) return -1;
if(c[0] == 1 && lst != 0) return lst = 0;
if(c[1] == 1 && lst != 1) return lst = 1;
exit(-1);
}
if(c[0] + c[1] == 2) {
if(c[0]) {
cur.pb('0'+c[1]);
cur.pb('0');
return lst = 0;
}
cur += "11";
return lst = 1;
}
if(gg) return lst = c[1];
cur.pb('0'+c[1]);
if(cur.size() == 5) {
gg = 1;
//cout << " " << gg << "Yay\n";
if(god.find(cur) != string::npos) return -1;
}
return lst = c[1];
}
} // namespace
void Init(int A, int B) {
kate::A = A;
kate::B = B;
}
int Move(std::vector<int> y) {
//cout << y[0] << " " << y[1] << " go ";
int t = kate::decide(y);
//cout <<kate::cur << " " << t << endl;
return t;
}
Compilation message
Anthony.cpp: In function 'void anton::dfs(int)':
Anthony.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < l.size(); i++) val[pidx[l[i]]] = god[(i+b)%6];
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
21404 KB |
Output is correct |
2 |
Correct |
14 ms |
13056 KB |
Output is correct |
3 |
Correct |
51 ms |
21116 KB |
Output is correct |
4 |
Correct |
70 ms |
22764 KB |
Output is correct |
5 |
Correct |
76 ms |
22912 KB |
Output is correct |
6 |
Correct |
58 ms |
21404 KB |
Output is correct |
7 |
Correct |
59 ms |
21384 KB |
Output is correct |
8 |
Correct |
66 ms |
22228 KB |
Output is correct |
9 |
Correct |
69 ms |
22164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
21404 KB |
Output is correct |
2 |
Correct |
14 ms |
13056 KB |
Output is correct |
3 |
Correct |
51 ms |
21116 KB |
Output is correct |
4 |
Correct |
70 ms |
22764 KB |
Output is correct |
5 |
Correct |
76 ms |
22912 KB |
Output is correct |
6 |
Correct |
58 ms |
21404 KB |
Output is correct |
7 |
Correct |
59 ms |
21384 KB |
Output is correct |
8 |
Correct |
66 ms |
22228 KB |
Output is correct |
9 |
Correct |
69 ms |
22164 KB |
Output is correct |
10 |
Correct |
57 ms |
19596 KB |
Output is correct |
11 |
Incorrect |
56 ms |
19508 KB |
Wrong Answer [6] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
19548 KB |
Output is correct |
2 |
Correct |
12 ms |
13056 KB |
Output is correct |
3 |
Correct |
49 ms |
18832 KB |
Output is correct |
4 |
Correct |
69 ms |
20596 KB |
Output is correct |
5 |
Correct |
71 ms |
20736 KB |
Output is correct |
6 |
Correct |
56 ms |
19460 KB |
Output is correct |
7 |
Correct |
57 ms |
19448 KB |
Output is correct |
8 |
Correct |
63 ms |
19976 KB |
Output is correct |
9 |
Correct |
63 ms |
20036 KB |
Output is correct |
10 |
Correct |
61 ms |
19780 KB |
Output is correct |
11 |
Correct |
65 ms |
19772 KB |
Output is correct |
12 |
Correct |
65 ms |
19772 KB |
Output is correct |
13 |
Correct |
63 ms |
19600 KB |
Output is correct |
14 |
Correct |
66 ms |
20032 KB |
Output is correct |
15 |
Correct |
64 ms |
20040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
19548 KB |
Output is correct |
2 |
Correct |
12 ms |
13056 KB |
Output is correct |
3 |
Correct |
49 ms |
18832 KB |
Output is correct |
4 |
Correct |
69 ms |
20596 KB |
Output is correct |
5 |
Correct |
71 ms |
20736 KB |
Output is correct |
6 |
Correct |
56 ms |
19460 KB |
Output is correct |
7 |
Correct |
57 ms |
19448 KB |
Output is correct |
8 |
Correct |
63 ms |
19976 KB |
Output is correct |
9 |
Correct |
63 ms |
20036 KB |
Output is correct |
10 |
Correct |
61 ms |
19780 KB |
Output is correct |
11 |
Correct |
65 ms |
19772 KB |
Output is correct |
12 |
Correct |
65 ms |
19772 KB |
Output is correct |
13 |
Correct |
63 ms |
19600 KB |
Output is correct |
14 |
Correct |
66 ms |
20032 KB |
Output is correct |
15 |
Correct |
64 ms |
20040 KB |
Output is correct |
16 |
Incorrect |
50 ms |
17676 KB |
Wrong Answer [6] |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
13056 KB |
Output is correct |
2 |
Correct |
13 ms |
13056 KB |
Output is correct |
3 |
Correct |
13 ms |
13056 KB |
Output is correct |
4 |
Correct |
13 ms |
13056 KB |
Output is correct |
5 |
Correct |
13 ms |
13056 KB |
Output is correct |
6 |
Correct |
13 ms |
13056 KB |
Output is correct |
7 |
Correct |
13 ms |
13056 KB |
Output is correct |
8 |
Correct |
13 ms |
13056 KB |
Output is correct |
9 |
Correct |
14 ms |
13056 KB |
Output is correct |
10 |
Correct |
16 ms |
13056 KB |
Output is correct |
11 |
Correct |
13 ms |
13056 KB |
Output is correct |
12 |
Correct |
13 ms |
13056 KB |
Output is correct |
13 |
Correct |
14 ms |
13056 KB |
Output is correct |
14 |
Correct |
13 ms |
13056 KB |
Output is correct |
15 |
Correct |
13 ms |
13056 KB |
Output is correct |
16 |
Correct |
13 ms |
13056 KB |
Output is correct |
17 |
Correct |
13 ms |
13056 KB |
Output is correct |
18 |
Correct |
13 ms |
13312 KB |
Output is correct |
19 |
Correct |
13 ms |
13056 KB |
Output is correct |
20 |
Correct |
13 ms |
13056 KB |
Output is correct |
21 |
Correct |
13 ms |
13056 KB |
Output is correct |
22 |
Correct |
15 ms |
13056 KB |
Output is correct |
23 |
Correct |
13 ms |
13056 KB |
Output is correct |
24 |
Correct |
13 ms |
13056 KB |
Output is correct |
25 |
Correct |
16 ms |
13056 KB |
Output is correct |
26 |
Correct |
13 ms |
13056 KB |
Output is correct |
27 |
Correct |
14 ms |
13056 KB |
Output is correct |
28 |
Correct |
16 ms |
13056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
17532 KB |
Output is correct |
2 |
Correct |
80 ms |
19024 KB |
Output is correct |
3 |
Correct |
12 ms |
13056 KB |
Output is correct |
4 |
Correct |
48 ms |
17404 KB |
Output is correct |
5 |
Correct |
66 ms |
20324 KB |
Output is correct |
6 |
Correct |
67 ms |
20416 KB |
Output is correct |
7 |
Correct |
55 ms |
19944 KB |
Output is correct |
8 |
Correct |
55 ms |
19808 KB |
Output is correct |
9 |
Correct |
71 ms |
20444 KB |
Output is correct |
10 |
Correct |
66 ms |
20300 KB |
Output is correct |
11 |
Correct |
66 ms |
20308 KB |
Output is correct |
12 |
Correct |
69 ms |
20320 KB |
Output is correct |
13 |
Correct |
68 ms |
20296 KB |
Output is correct |
14 |
Correct |
67 ms |
20432 KB |
Output is correct |
15 |
Correct |
66 ms |
20312 KB |
Output is correct |
16 |
Correct |
67 ms |
20504 KB |
Output is correct |
17 |
Correct |
66 ms |
20184 KB |
Output is correct |
18 |
Correct |
64 ms |
20056 KB |
Output is correct |
19 |
Correct |
63 ms |
20048 KB |
Output is correct |
20 |
Correct |
63 ms |
20064 KB |
Output is correct |
21 |
Correct |
66 ms |
20060 KB |
Output is correct |
22 |
Correct |
63 ms |
19904 KB |
Output is correct |
23 |
Correct |
53 ms |
17652 KB |
Output is correct |
24 |
Correct |
56 ms |
17720 KB |
Output is correct |
25 |
Correct |
55 ms |
18044 KB |
Output is correct |
26 |
Correct |
55 ms |
18092 KB |
Output is correct |
27 |
Correct |
61 ms |
19176 KB |
Output is correct |
28 |
Correct |
69 ms |
19060 KB |
Output is correct |
29 |
Correct |
61 ms |
19152 KB |
Output is correct |
30 |
Correct |
73 ms |
19136 KB |
Output is correct |
31 |
Correct |
55 ms |
17668 KB |
Output is correct |
32 |
Correct |
55 ms |
17868 KB |
Output is correct |
33 |
Correct |
64 ms |
18060 KB |
Output is correct |
34 |
Correct |
55 ms |
18072 KB |
Output is correct |
35 |
Correct |
60 ms |
18852 KB |
Output is correct |
36 |
Correct |
64 ms |
18848 KB |
Output is correct |
37 |
Correct |
61 ms |
18804 KB |
Output is correct |
38 |
Correct |
60 ms |
18852 KB |
Output is correct |
39 |
Correct |
61 ms |
18804 KB |
Output is correct |
40 |
Correct |
61 ms |
18856 KB |
Output is correct |
41 |
Correct |
66 ms |
19536 KB |
Output is correct |
42 |
Correct |
62 ms |
19452 KB |
Output is correct |
43 |
Correct |
63 ms |
19540 KB |
Output is correct |
44 |
Correct |
67 ms |
19664 KB |
Output is correct |
45 |
Correct |
65 ms |
19824 KB |
Output is correct |
46 |
Correct |
64 ms |
19668 KB |
Output is correct |
47 |
Correct |
59 ms |
18556 KB |
Output is correct |
48 |
Correct |
60 ms |
18812 KB |
Output is correct |
49 |
Correct |
59 ms |
18548 KB |
Output is correct |
50 |
Correct |
58 ms |
18680 KB |
Output is correct |
51 |
Correct |
64 ms |
17932 KB |
Output is correct |
52 |
Correct |
55 ms |
17928 KB |
Output is correct |
53 |
Correct |
57 ms |
17928 KB |
Output is correct |
54 |
Correct |
54 ms |
17924 KB |
Output is correct |
55 |
Correct |
55 ms |
17920 KB |
Output is correct |
56 |
Correct |
54 ms |
17916 KB |
Output is correct |
57 |
Correct |
59 ms |
17908 KB |
Output is correct |
58 |
Correct |
59 ms |
17956 KB |
Output is correct |
59 |
Correct |
55 ms |
17856 KB |
Output is correct |
60 |
Correct |
58 ms |
17788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
17692 KB |
Output is correct |
2 |
Correct |
57 ms |
18916 KB |
Output is correct |
3 |
Correct |
14 ms |
13056 KB |
Output is correct |
4 |
Correct |
48 ms |
17436 KB |
Output is correct |
5 |
Correct |
65 ms |
20440 KB |
Output is correct |
6 |
Correct |
67 ms |
20328 KB |
Output is correct |
7 |
Correct |
56 ms |
19808 KB |
Output is correct |
8 |
Correct |
57 ms |
19808 KB |
Output is correct |
9 |
Correct |
66 ms |
20308 KB |
Output is correct |
10 |
Correct |
68 ms |
20308 KB |
Output is correct |
11 |
Correct |
66 ms |
20436 KB |
Output is correct |
12 |
Correct |
68 ms |
20308 KB |
Output is correct |
13 |
Correct |
83 ms |
20456 KB |
Output is correct |
14 |
Correct |
69 ms |
20300 KB |
Output is correct |
15 |
Correct |
66 ms |
20396 KB |
Output is correct |
16 |
Correct |
72 ms |
20316 KB |
Output is correct |
17 |
Correct |
65 ms |
20268 KB |
Output is correct |
18 |
Correct |
63 ms |
20056 KB |
Output is correct |
19 |
Correct |
63 ms |
20056 KB |
Output is correct |
20 |
Correct |
65 ms |
19996 KB |
Output is correct |
21 |
Correct |
64 ms |
20060 KB |
Output is correct |
22 |
Correct |
63 ms |
20064 KB |
Output is correct |
23 |
Correct |
53 ms |
17724 KB |
Output is correct |
24 |
Correct |
57 ms |
17696 KB |
Output is correct |
25 |
Correct |
54 ms |
18044 KB |
Output is correct |
26 |
Correct |
54 ms |
18096 KB |
Output is correct |
27 |
Correct |
64 ms |
19172 KB |
Output is correct |
28 |
Correct |
63 ms |
19172 KB |
Output is correct |
29 |
Correct |
61 ms |
19148 KB |
Output is correct |
30 |
Correct |
61 ms |
19136 KB |
Output is correct |
31 |
Correct |
54 ms |
17744 KB |
Output is correct |
32 |
Correct |
55 ms |
17736 KB |
Output is correct |
33 |
Correct |
55 ms |
18084 KB |
Output is correct |
34 |
Correct |
56 ms |
18036 KB |
Output is correct |
35 |
Correct |
61 ms |
18864 KB |
Output is correct |
36 |
Correct |
63 ms |
18980 KB |
Output is correct |
37 |
Correct |
62 ms |
18952 KB |
Output is correct |
38 |
Correct |
62 ms |
18796 KB |
Output is correct |
39 |
Correct |
64 ms |
18856 KB |
Output is correct |
40 |
Correct |
61 ms |
18984 KB |
Output is correct |
41 |
Correct |
66 ms |
19652 KB |
Output is correct |
42 |
Correct |
65 ms |
19528 KB |
Output is correct |
43 |
Correct |
63 ms |
19452 KB |
Output is correct |
44 |
Correct |
63 ms |
19648 KB |
Output is correct |
45 |
Correct |
66 ms |
19664 KB |
Output is correct |
46 |
Correct |
64 ms |
19656 KB |
Output is correct |
47 |
Correct |
59 ms |
18692 KB |
Output is correct |
48 |
Correct |
59 ms |
18620 KB |
Output is correct |
49 |
Correct |
57 ms |
18692 KB |
Output is correct |
50 |
Correct |
60 ms |
18684 KB |
Output is correct |
51 |
Correct |
54 ms |
18060 KB |
Output is correct |
52 |
Correct |
55 ms |
17916 KB |
Output is correct |
53 |
Correct |
55 ms |
18128 KB |
Output is correct |
54 |
Correct |
55 ms |
18044 KB |
Output is correct |
55 |
Correct |
53 ms |
17960 KB |
Output is correct |
56 |
Correct |
56 ms |
17796 KB |
Output is correct |
57 |
Correct |
56 ms |
17816 KB |
Output is correct |
58 |
Correct |
55 ms |
17944 KB |
Output is correct |
59 |
Correct |
54 ms |
17872 KB |
Output is correct |
60 |
Correct |
55 ms |
17852 KB |
Output is correct |