#include "Anthony.h"
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#define PB push_back
#define X first
#define Y second
using namespace std;
namespace {
const int N = 2e4 + 500;
int kljuc[6] = {1, 1, 0, 0, 1, 0};
int tko[N], dep[N], col[N], par[N], dis[N];
vector < int > v2[N];
vector < int > v[N];
void dfs_glup(int x, int lst){
dep[x] = dep[lst] + 1;
par[x] = lst;
if(lst != x)
v[lst].PB(x);
for(int y : v2[x])
if(y != lst)
dfs_glup(y, x);
}
void dfs_pametan(int x){
if(v[par[x]].size() > 1 || !par[x]){
col[x] = !col[par[x]];
for(int y : v[x])
dfs_pametan(y);
return;
}
if(!par[par[x]] || (v[par[par[x]]].size() > 1)){
if(!col[par[x]])
tko[par[x]] = 2;
}
tko[x] = (tko[par[x]] + 1) % 6;
col[x] = kljuc[tko[x]];
for(int y : v[x])
dfs_pametan(y);
}
void bfs(){
queue < int > q; q.push(0); dis[0] = 1;
for(;!q.empty();q.pop()){
int cur = q.front();
for(int y : v[cur]){
if(!dis[y]){
dis[y] = dis[cur] + 1;
q.push(y);
}
}
}
}
} // namespace
vector<int> Mark(int n, int m, int a, int b, vector<int> u1, vector<int> u2) {
vector < int > ans(m);
if(a == 2){
for(int i = 0;i < m;i++){
v2[u1[i]].PB(u2[i]);
v2[u2[i]].PB(u1[i]);
}
dfs_glup(0, 0);// printf("glup gotov\n");
for(int y : v[0]) dfs_pametan(y);
//for(int i = 1;i < n;i++) printf("col[ %d ] = %d\n", i, col[i]);
for(int i = 0;i < m;i++){
if(dep[u1[i]] > dep[u2[i]])
ans[i] = col[u1[i]];
else
ans[i] = col[u2[i]];
}
return ans;
}
else{
for(int i = 0;i < m;i++){
v[u1[i]].PB(u2[i]);
v[u2[i]].PB(u1[i]);
}
bfs();
for(int i = 0;i < m;i++){
ans[i] = min(dis[u1[i]], dis[u2[i]]) % 3;
}
return ans;
}
}
#include "Catherine.h"
#include <vector>
#include <cstdio>
#define PB push_back
using namespace std;
namespace {
int lst, start = 1;
vector < int > pamt;
int jednostavno = 0;
int AA = 0;
} // namespace
void Init(int A, int B) {
AA = A;
}
int Move(std::vector<int> y) {
if(AA == 2){
if(start){
start = 0;
if(y[0] + y[1] > 2){
return lst = (y[0] > y[1]);
}
if(y[0] + y[1] == 1){
jednostavno = 1;
return lst = y[1];
}
if(y[1]){
pamt.PB(1);
pamt.PB(y[1] - 1);
return lst = y[1] - 1;
}
else{
pamt.PB(0);
pamt.PB(0);
return lst = 0;
}
}
if(jednostavno){
if(y[0] + y[1] == 1)
return lst = y[1];
if(y[0] == y[1])
return lst = !lst;
return lst = (y[0] > y[1]);
}
if(y[0] + y[1] == 0){
jednostavno = 1;
return -1;
}
if(y[0] + y[1] > 1){
jednostavno = 1;
if(y[0] == 0 || y[1] == 0){
return -1;
}
if(y[0] != y[1]){
return lst = (y[0] > y[1]);
}
if(y[0] == y[1]){
return lst = !lst;
}
}
pamt.PB(y[1]);
if((int)pamt.size() == 5){
bool jed = (pamt == (vector<int>){1, 1, 0, 0, 1});
jed |= (pamt == (vector<int>){1, 0, 0, 1, 0});
jed |= (pamt == (vector<int>){0, 0, 1, 0, 1});
jed |= (pamt == (vector<int>){0, 1, 0, 1, 1});
jed |= (pamt == (vector<int>){1, 0, 1, 1, 0});
jed |= (pamt == (vector<int>){0, 1, 1, 0, 0});
jednostavno = 1;
if(jed){
return -1;
}
else{
return lst = y[1];
}
}
return lst = y[1];
}
else{
if(!!y[0] + !!y[1] + !!y[2] == 1){
if(y[0])
return 0;
if(y[1])
return 1;
return 2;
}
else{
if(!y[0])
return 1;
if(!y[1])
return 2;
return 0;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
16332 KB |
Output is correct |
2 |
Correct |
13 ms |
2560 KB |
Output is correct |
3 |
Correct |
89 ms |
15796 KB |
Output is correct |
4 |
Correct |
86 ms |
17672 KB |
Output is correct |
5 |
Correct |
74 ms |
17612 KB |
Output is correct |
6 |
Correct |
69 ms |
16228 KB |
Output is correct |
7 |
Correct |
76 ms |
16192 KB |
Output is correct |
8 |
Correct |
97 ms |
16992 KB |
Output is correct |
9 |
Correct |
82 ms |
16976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
16332 KB |
Output is correct |
2 |
Correct |
13 ms |
2560 KB |
Output is correct |
3 |
Correct |
89 ms |
15796 KB |
Output is correct |
4 |
Correct |
86 ms |
17672 KB |
Output is correct |
5 |
Correct |
74 ms |
17612 KB |
Output is correct |
6 |
Correct |
69 ms |
16228 KB |
Output is correct |
7 |
Correct |
76 ms |
16192 KB |
Output is correct |
8 |
Correct |
97 ms |
16992 KB |
Output is correct |
9 |
Correct |
82 ms |
16976 KB |
Output is correct |
10 |
Correct |
75 ms |
14464 KB |
Output is correct |
11 |
Correct |
61 ms |
14408 KB |
Output is correct |
12 |
Correct |
56 ms |
14516 KB |
Output is correct |
13 |
Correct |
60 ms |
14280 KB |
Output is correct |
14 |
Correct |
74 ms |
14560 KB |
Output is correct |
15 |
Correct |
69 ms |
14916 KB |
Output is correct |
16 |
Correct |
94 ms |
17128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
13996 KB |
Output is correct |
2 |
Correct |
11 ms |
2560 KB |
Output is correct |
3 |
Correct |
55 ms |
13552 KB |
Output is correct |
4 |
Correct |
72 ms |
15496 KB |
Output is correct |
5 |
Correct |
73 ms |
15500 KB |
Output is correct |
6 |
Correct |
56 ms |
14052 KB |
Output is correct |
7 |
Correct |
57 ms |
14044 KB |
Output is correct |
8 |
Correct |
73 ms |
14668 KB |
Output is correct |
9 |
Correct |
70 ms |
14900 KB |
Output is correct |
10 |
Correct |
72 ms |
14472 KB |
Output is correct |
11 |
Correct |
57 ms |
14560 KB |
Output is correct |
12 |
Correct |
66 ms |
14424 KB |
Output is correct |
13 |
Correct |
72 ms |
14436 KB |
Output is correct |
14 |
Correct |
67 ms |
14852 KB |
Output is correct |
15 |
Correct |
76 ms |
14804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
13996 KB |
Output is correct |
2 |
Correct |
11 ms |
2560 KB |
Output is correct |
3 |
Correct |
55 ms |
13552 KB |
Output is correct |
4 |
Correct |
72 ms |
15496 KB |
Output is correct |
5 |
Correct |
73 ms |
15500 KB |
Output is correct |
6 |
Correct |
56 ms |
14052 KB |
Output is correct |
7 |
Correct |
57 ms |
14044 KB |
Output is correct |
8 |
Correct |
73 ms |
14668 KB |
Output is correct |
9 |
Correct |
70 ms |
14900 KB |
Output is correct |
10 |
Correct |
72 ms |
14472 KB |
Output is correct |
11 |
Correct |
57 ms |
14560 KB |
Output is correct |
12 |
Correct |
66 ms |
14424 KB |
Output is correct |
13 |
Correct |
72 ms |
14436 KB |
Output is correct |
14 |
Correct |
67 ms |
14852 KB |
Output is correct |
15 |
Correct |
76 ms |
14804 KB |
Output is correct |
16 |
Correct |
52 ms |
12464 KB |
Output is correct |
17 |
Correct |
57 ms |
12392 KB |
Output is correct |
18 |
Correct |
66 ms |
12604 KB |
Output is correct |
19 |
Correct |
49 ms |
12604 KB |
Output is correct |
20 |
Correct |
56 ms |
13040 KB |
Output is correct |
21 |
Correct |
55 ms |
12876 KB |
Output is correct |
22 |
Correct |
78 ms |
14960 KB |
Output is correct |
23 |
Correct |
53 ms |
12604 KB |
Output is correct |
24 |
Correct |
51 ms |
12504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
2816 KB |
Output is correct |
2 |
Correct |
10 ms |
2560 KB |
Output is correct |
3 |
Correct |
10 ms |
2560 KB |
Output is correct |
4 |
Correct |
11 ms |
2816 KB |
Output is correct |
5 |
Correct |
11 ms |
2816 KB |
Output is correct |
6 |
Correct |
12 ms |
2816 KB |
Output is correct |
7 |
Correct |
11 ms |
2816 KB |
Output is correct |
8 |
Correct |
12 ms |
2816 KB |
Output is correct |
9 |
Correct |
11 ms |
2816 KB |
Output is correct |
10 |
Correct |
11 ms |
2816 KB |
Output is correct |
11 |
Correct |
11 ms |
2816 KB |
Output is correct |
12 |
Correct |
11 ms |
2560 KB |
Output is correct |
13 |
Correct |
11 ms |
2816 KB |
Output is correct |
14 |
Correct |
12 ms |
2560 KB |
Output is correct |
15 |
Correct |
11 ms |
2816 KB |
Output is correct |
16 |
Correct |
11 ms |
2560 KB |
Output is correct |
17 |
Correct |
11 ms |
2560 KB |
Output is correct |
18 |
Correct |
11 ms |
2880 KB |
Output is correct |
19 |
Correct |
11 ms |
2560 KB |
Output is correct |
20 |
Correct |
11 ms |
2560 KB |
Output is correct |
21 |
Correct |
10 ms |
2560 KB |
Output is correct |
22 |
Correct |
10 ms |
2560 KB |
Output is correct |
23 |
Correct |
11 ms |
2560 KB |
Output is correct |
24 |
Correct |
11 ms |
2816 KB |
Output is correct |
25 |
Correct |
10 ms |
2560 KB |
Output is correct |
26 |
Correct |
11 ms |
2816 KB |
Output is correct |
27 |
Correct |
15 ms |
2560 KB |
Output is correct |
28 |
Correct |
18 ms |
2560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
12524 KB |
Output is correct |
2 |
Correct |
71 ms |
13636 KB |
Output is correct |
3 |
Correct |
9 ms |
2560 KB |
Output is correct |
4 |
Correct |
64 ms |
12412 KB |
Output is correct |
5 |
Correct |
86 ms |
15356 KB |
Output is correct |
6 |
Correct |
80 ms |
15236 KB |
Output is correct |
7 |
Correct |
72 ms |
14352 KB |
Output is correct |
8 |
Correct |
63 ms |
14448 KB |
Output is correct |
9 |
Correct |
82 ms |
15180 KB |
Output is correct |
10 |
Correct |
94 ms |
15228 KB |
Output is correct |
11 |
Correct |
77 ms |
15232 KB |
Output is correct |
12 |
Correct |
69 ms |
15248 KB |
Output is correct |
13 |
Correct |
74 ms |
15216 KB |
Output is correct |
14 |
Correct |
82 ms |
15224 KB |
Output is correct |
15 |
Correct |
68 ms |
15188 KB |
Output is correct |
16 |
Correct |
70 ms |
15240 KB |
Output is correct |
17 |
Correct |
66 ms |
14924 KB |
Output is correct |
18 |
Correct |
65 ms |
14924 KB |
Output is correct |
19 |
Correct |
63 ms |
14840 KB |
Output is correct |
20 |
Correct |
70 ms |
14964 KB |
Output is correct |
21 |
Correct |
65 ms |
14984 KB |
Output is correct |
22 |
Correct |
72 ms |
14968 KB |
Output is correct |
23 |
Correct |
63 ms |
12780 KB |
Output is correct |
24 |
Correct |
52 ms |
12736 KB |
Output is correct |
25 |
Correct |
57 ms |
13028 KB |
Output is correct |
26 |
Correct |
73 ms |
13012 KB |
Output is correct |
27 |
Correct |
73 ms |
13772 KB |
Output is correct |
28 |
Correct |
60 ms |
13852 KB |
Output is correct |
29 |
Correct |
73 ms |
13836 KB |
Output is correct |
30 |
Correct |
61 ms |
13852 KB |
Output is correct |
31 |
Correct |
54 ms |
12620 KB |
Output is correct |
32 |
Correct |
64 ms |
12776 KB |
Output is correct |
33 |
Correct |
54 ms |
13008 KB |
Output is correct |
34 |
Correct |
64 ms |
13008 KB |
Output is correct |
35 |
Correct |
72 ms |
13652 KB |
Output is correct |
36 |
Correct |
64 ms |
13568 KB |
Output is correct |
37 |
Correct |
74 ms |
13772 KB |
Output is correct |
38 |
Correct |
65 ms |
13652 KB |
Output is correct |
39 |
Correct |
96 ms |
13576 KB |
Output is correct |
40 |
Correct |
74 ms |
13620 KB |
Output is correct |
41 |
Correct |
79 ms |
14292 KB |
Output is correct |
42 |
Correct |
82 ms |
14268 KB |
Output is correct |
43 |
Correct |
104 ms |
14400 KB |
Output is correct |
44 |
Correct |
74 ms |
14376 KB |
Output is correct |
45 |
Correct |
81 ms |
14236 KB |
Output is correct |
46 |
Correct |
95 ms |
14288 KB |
Output is correct |
47 |
Correct |
65 ms |
13416 KB |
Output is correct |
48 |
Correct |
72 ms |
13500 KB |
Output is correct |
49 |
Correct |
61 ms |
13464 KB |
Output is correct |
50 |
Correct |
67 ms |
13516 KB |
Output is correct |
51 |
Correct |
63 ms |
12884 KB |
Output is correct |
52 |
Correct |
67 ms |
12792 KB |
Output is correct |
53 |
Correct |
62 ms |
12696 KB |
Output is correct |
54 |
Correct |
72 ms |
12796 KB |
Output is correct |
55 |
Correct |
57 ms |
12864 KB |
Output is correct |
56 |
Correct |
59 ms |
12784 KB |
Output is correct |
57 |
Correct |
80 ms |
13056 KB |
Output is correct |
58 |
Correct |
85 ms |
13004 KB |
Output is correct |
59 |
Correct |
80 ms |
13268 KB |
Output is correct |
60 |
Correct |
56 ms |
13384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
12368 KB |
Output is correct |
2 |
Correct |
64 ms |
13524 KB |
Output is correct |
3 |
Correct |
10 ms |
2560 KB |
Output is correct |
4 |
Correct |
53 ms |
12344 KB |
Output is correct |
5 |
Correct |
103 ms |
15224 KB |
Output is correct |
6 |
Correct |
96 ms |
15268 KB |
Output is correct |
7 |
Correct |
69 ms |
14300 KB |
Output is correct |
8 |
Correct |
63 ms |
14284 KB |
Output is correct |
9 |
Correct |
77 ms |
15200 KB |
Output is correct |
10 |
Correct |
71 ms |
15180 KB |
Output is correct |
11 |
Correct |
73 ms |
15276 KB |
Output is correct |
12 |
Correct |
68 ms |
15204 KB |
Output is correct |
13 |
Correct |
73 ms |
15180 KB |
Output is correct |
14 |
Correct |
68 ms |
15180 KB |
Output is correct |
15 |
Correct |
74 ms |
15280 KB |
Output is correct |
16 |
Correct |
72 ms |
15308 KB |
Output is correct |
17 |
Correct |
69 ms |
14924 KB |
Output is correct |
18 |
Correct |
76 ms |
14928 KB |
Output is correct |
19 |
Correct |
61 ms |
14968 KB |
Output is correct |
20 |
Correct |
73 ms |
14796 KB |
Output is correct |
21 |
Correct |
66 ms |
14932 KB |
Output is correct |
22 |
Correct |
66 ms |
14976 KB |
Output is correct |
23 |
Correct |
63 ms |
12736 KB |
Output is correct |
24 |
Correct |
59 ms |
12500 KB |
Output is correct |
25 |
Correct |
54 ms |
13008 KB |
Output is correct |
26 |
Correct |
55 ms |
13124 KB |
Output is correct |
27 |
Correct |
66 ms |
13856 KB |
Output is correct |
28 |
Correct |
68 ms |
13736 KB |
Output is correct |
29 |
Correct |
66 ms |
13852 KB |
Output is correct |
30 |
Correct |
78 ms |
13764 KB |
Output is correct |
31 |
Correct |
54 ms |
12728 KB |
Output is correct |
32 |
Correct |
69 ms |
12740 KB |
Output is correct |
33 |
Correct |
55 ms |
12876 KB |
Output is correct |
34 |
Correct |
55 ms |
13020 KB |
Output is correct |
35 |
Correct |
72 ms |
13516 KB |
Output is correct |
36 |
Correct |
67 ms |
13660 KB |
Output is correct |
37 |
Correct |
72 ms |
13504 KB |
Output is correct |
38 |
Correct |
60 ms |
13516 KB |
Output is correct |
39 |
Correct |
60 ms |
13784 KB |
Output is correct |
40 |
Correct |
74 ms |
13516 KB |
Output is correct |
41 |
Correct |
69 ms |
14276 KB |
Output is correct |
42 |
Correct |
65 ms |
14316 KB |
Output is correct |
43 |
Correct |
82 ms |
14284 KB |
Output is correct |
44 |
Correct |
66 ms |
14288 KB |
Output is correct |
45 |
Correct |
66 ms |
14560 KB |
Output is correct |
46 |
Correct |
60 ms |
14380 KB |
Output is correct |
47 |
Correct |
59 ms |
13560 KB |
Output is correct |
48 |
Correct |
78 ms |
13548 KB |
Output is correct |
49 |
Correct |
58 ms |
13464 KB |
Output is correct |
50 |
Correct |
67 ms |
13568 KB |
Output is correct |
51 |
Correct |
62 ms |
12876 KB |
Output is correct |
52 |
Correct |
83 ms |
12824 KB |
Output is correct |
53 |
Correct |
59 ms |
12960 KB |
Output is correct |
54 |
Correct |
57 ms |
12832 KB |
Output is correct |
55 |
Correct |
75 ms |
12876 KB |
Output is correct |
56 |
Correct |
57 ms |
12884 KB |
Output is correct |
57 |
Correct |
61 ms |
13036 KB |
Output is correct |
58 |
Correct |
57 ms |
13148 KB |
Output is correct |
59 |
Correct |
54 ms |
13384 KB |
Output is correct |
60 |
Correct |
56 ms |
13260 KB |
Output is correct |