#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
string str="001011";
const int N=20005;
vector<int> v,adj[N+1],deg(N),e(N);
const int INF=1e9;
void dfs(int k,int pa,int dis,int up){
for(int i:adj[k]){
int j=e[i]^k;
if(j==pa)continue;
if(deg[k]<=2){
v[i]=str[dis%6]-'0';
dfs(j,k,dis+1,v[i]);
}
else{
v[i]=up^1;
if(v[i]==1)dfs(j,k,3,v[i]);
else dfs(j,k,1,v[i]);
}
}
}
vector<int> Mark(int N, int M, int A, int B,vector<int> U, vector<int> V) {
if(A>=3){
vector<int> v(M,-1),adj[N+1];
queue<int> q;
vector<int> dis(N+1,INF);
for(int i=0;i<M;i++){
adj[U[i]].push_back(i);
adj[V[i]].push_back(i);
}
q.push(0);
dis[0]=0;
while(q.size()){
int p=q.front();
q.pop();
for(int j:adj[p]){
if(v[j]==-1){
v[j]=dis[p]%3;
}
}
for(int i:adj[p]){
int j=(U[i]==p?V[i]:U[i]);
if(dis[j]==INF){
dis[j]=dis[p]+1;
v[i]=dis[p]%3;
q.push(j);
}
}
}
return v;
}
v.resize(M,-1);
queue<int> q;
vector<int> dis(N+1,INF);
for(int i=0;i<M;i++){
adj[U[i]].push_back(i);
adj[V[i]].push_back(i);
deg[U[i]]++;
deg[V[i]]++;
e[i]=U[i]^V[i];
}
dfs(0,0,0,0);
return v;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
int last=-1,sure=0;
vector<int> tmp={0,0,1,0,1,1};
vector<int> rec;
int a,b;
void Init(int A, int B) {
a=A,b=B;
}
int Move2(vector<int> y) {
//cout<<y[0]<<' '<<y[1]<<' '<<last<<endl;
if(sure){
int tot=y[0]+y[1];
if(min(y[0],y[1])==0){
return last=(y[0]?0:1);
}
else{
if(y[last^1]==0)cout<<"NO"<<endl;
return last=last^1;
}
}
if(last==-1){
int tot=y[0]+y[1];
if(tot==1){
sure=1;
last=(y[0]?0:1);
return last;
}
else if(tot==2){
if(y[0]&&y[1]){
rec.push_back(0);
rec.push_back(1);
return last=1;
}
else if(y[0]==2){
rec.push_back(0);
rec.push_back(0);
return last=0;
}
else{
rec.push_back(1);
rec.push_back(1);
return last=1;
}
}
else{
sure=1;
last=(y[0]>y[1]?1:0);
assert(y[last]!=0);
return last;
}
}
else{
int tot=y[0]+y[1];
if(tot==0){
sure=1;
return -1;
}
else if(tot==1){
rec.push_back((y[0]?0:1));
if(rec.size()==5){
int flag=0;
for(int i=0;i<6;i++){
vector<int> a(tmp.begin(),tmp.begin()+5);
if(a==rec){
flag=1;
break;
}
rotate(tmp.begin(),tmp.begin()+1,tmp.end());
}
if(flag==0){
sure=1;
return last=(y[0]?0:1);
}
else{
sure=1;
return -1;
}
}
else{
last=(y[0]?0:1);
return last;
}
}
else{
y[last]++;
if(y[0]==1){
int t=(last==0?-1:0);
last=0;
sure=1;
return t;
}
else{
int t=(last==1?-1:1);
last=1;
sure=1;
return t;
}
}
}
assert(false);
}
int Move3(vector<int> y) {
if(y[0]==0&&y[1]==0)return 2;
if(y[1]==0&&y[2]==0)return 0;
if(y[2]==0&&y[0]==0)return 1;
if(y[0]&&y[1])return 0;
if(y[1]&&y[2])return 1;
if(y[2]&&y[0])return 2;
}
int Move(vector<int> y){
if(a==2){
return Move2(y);
}
else{
return Move3(y);
}
}
Compilation message
Catherine.cpp: In function 'int Move2(std::vector<int>)':
Catherine.cpp:15:7: warning: unused variable 'tot' [-Wunused-variable]
15 | int tot=y[0]+y[1];
| ^~~
Catherine.cpp: In function 'int Move3(std::vector<int>)':
Catherine.cpp:113:1: warning: control reaches end of non-void function [-Wreturn-type]
113 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
16180 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
24 ms |
15916 KB |
Output is correct |
4 |
Correct |
35 ms |
17704 KB |
Output is correct |
5 |
Correct |
34 ms |
17660 KB |
Output is correct |
6 |
Correct |
28 ms |
16168 KB |
Output is correct |
7 |
Correct |
30 ms |
16448 KB |
Output is correct |
8 |
Correct |
32 ms |
17144 KB |
Output is correct |
9 |
Correct |
33 ms |
17152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
16180 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
24 ms |
15916 KB |
Output is correct |
4 |
Correct |
35 ms |
17704 KB |
Output is correct |
5 |
Correct |
34 ms |
17660 KB |
Output is correct |
6 |
Correct |
28 ms |
16168 KB |
Output is correct |
7 |
Correct |
30 ms |
16448 KB |
Output is correct |
8 |
Correct |
32 ms |
17144 KB |
Output is correct |
9 |
Correct |
33 ms |
17152 KB |
Output is correct |
10 |
Correct |
26 ms |
14236 KB |
Output is correct |
11 |
Correct |
26 ms |
14416 KB |
Output is correct |
12 |
Correct |
27 ms |
14200 KB |
Output is correct |
13 |
Correct |
27 ms |
14392 KB |
Output is correct |
14 |
Correct |
27 ms |
14512 KB |
Output is correct |
15 |
Correct |
32 ms |
14920 KB |
Output is correct |
16 |
Correct |
31 ms |
17244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
13676 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
23 ms |
13160 KB |
Output is correct |
4 |
Correct |
35 ms |
15224 KB |
Output is correct |
5 |
Correct |
33 ms |
15224 KB |
Output is correct |
6 |
Correct |
26 ms |
13676 KB |
Output is correct |
7 |
Correct |
27 ms |
14144 KB |
Output is correct |
8 |
Correct |
31 ms |
14888 KB |
Output is correct |
9 |
Correct |
30 ms |
14844 KB |
Output is correct |
10 |
Correct |
31 ms |
14608 KB |
Output is correct |
11 |
Correct |
28 ms |
14612 KB |
Output is correct |
12 |
Correct |
28 ms |
14924 KB |
Output is correct |
13 |
Correct |
28 ms |
14676 KB |
Output is correct |
14 |
Correct |
32 ms |
14920 KB |
Output is correct |
15 |
Correct |
37 ms |
14808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
13676 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
23 ms |
13160 KB |
Output is correct |
4 |
Correct |
35 ms |
15224 KB |
Output is correct |
5 |
Correct |
33 ms |
15224 KB |
Output is correct |
6 |
Correct |
26 ms |
13676 KB |
Output is correct |
7 |
Correct |
27 ms |
14144 KB |
Output is correct |
8 |
Correct |
31 ms |
14888 KB |
Output is correct |
9 |
Correct |
30 ms |
14844 KB |
Output is correct |
10 |
Correct |
31 ms |
14608 KB |
Output is correct |
11 |
Correct |
28 ms |
14612 KB |
Output is correct |
12 |
Correct |
28 ms |
14924 KB |
Output is correct |
13 |
Correct |
28 ms |
14676 KB |
Output is correct |
14 |
Correct |
32 ms |
14920 KB |
Output is correct |
15 |
Correct |
37 ms |
14808 KB |
Output is correct |
16 |
Correct |
25 ms |
12480 KB |
Output is correct |
17 |
Correct |
24 ms |
12380 KB |
Output is correct |
18 |
Correct |
25 ms |
12360 KB |
Output is correct |
19 |
Correct |
25 ms |
12304 KB |
Output is correct |
20 |
Correct |
27 ms |
13288 KB |
Output is correct |
21 |
Correct |
27 ms |
12944 KB |
Output is correct |
22 |
Correct |
32 ms |
15072 KB |
Output is correct |
23 |
Correct |
26 ms |
12428 KB |
Output is correct |
24 |
Correct |
25 ms |
12620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1568 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
1 ms |
1560 KB |
Output is correct |
4 |
Correct |
2 ms |
1824 KB |
Output is correct |
5 |
Correct |
2 ms |
1816 KB |
Output is correct |
6 |
Correct |
2 ms |
1824 KB |
Output is correct |
7 |
Correct |
2 ms |
1816 KB |
Output is correct |
8 |
Correct |
2 ms |
1832 KB |
Output is correct |
9 |
Correct |
2 ms |
1812 KB |
Output is correct |
10 |
Correct |
2 ms |
1808 KB |
Output is correct |
11 |
Correct |
1 ms |
1824 KB |
Output is correct |
12 |
Correct |
1 ms |
1824 KB |
Output is correct |
13 |
Correct |
2 ms |
1820 KB |
Output is correct |
14 |
Correct |
1 ms |
1816 KB |
Output is correct |
15 |
Correct |
2 ms |
1824 KB |
Output is correct |
16 |
Correct |
2 ms |
1812 KB |
Output is correct |
17 |
Correct |
2 ms |
1568 KB |
Output is correct |
18 |
Correct |
2 ms |
1560 KB |
Output is correct |
19 |
Correct |
1 ms |
1552 KB |
Output is correct |
20 |
Correct |
2 ms |
1568 KB |
Output is correct |
21 |
Correct |
1 ms |
1568 KB |
Output is correct |
22 |
Correct |
2 ms |
1568 KB |
Output is correct |
23 |
Correct |
1 ms |
1552 KB |
Output is correct |
24 |
Correct |
1 ms |
1820 KB |
Output is correct |
25 |
Correct |
2 ms |
1820 KB |
Output is correct |
26 |
Correct |
2 ms |
2072 KB |
Output is correct |
27 |
Correct |
2 ms |
1568 KB |
Output is correct |
28 |
Correct |
2 ms |
1572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
11364 KB |
Output is correct |
2 |
Correct |
27 ms |
12928 KB |
Output is correct |
3 |
Correct |
1 ms |
1292 KB |
Output is correct |
4 |
Correct |
22 ms |
11384 KB |
Output is correct |
5 |
Correct |
36 ms |
14704 KB |
Output is correct |
6 |
Correct |
34 ms |
14708 KB |
Output is correct |
7 |
Correct |
27 ms |
13664 KB |
Output is correct |
8 |
Correct |
27 ms |
13696 KB |
Output is correct |
9 |
Correct |
32 ms |
14712 KB |
Output is correct |
10 |
Correct |
32 ms |
14660 KB |
Output is correct |
11 |
Correct |
32 ms |
14708 KB |
Output is correct |
12 |
Correct |
31 ms |
14648 KB |
Output is correct |
13 |
Correct |
30 ms |
14572 KB |
Output is correct |
14 |
Correct |
35 ms |
14780 KB |
Output is correct |
15 |
Correct |
30 ms |
14668 KB |
Output is correct |
16 |
Correct |
32 ms |
14684 KB |
Output is correct |
17 |
Correct |
28 ms |
14456 KB |
Output is correct |
18 |
Correct |
30 ms |
14464 KB |
Output is correct |
19 |
Correct |
28 ms |
14456 KB |
Output is correct |
20 |
Correct |
34 ms |
14240 KB |
Output is correct |
21 |
Correct |
30 ms |
14444 KB |
Output is correct |
22 |
Correct |
31 ms |
14240 KB |
Output is correct |
23 |
Correct |
25 ms |
11384 KB |
Output is correct |
24 |
Correct |
24 ms |
11376 KB |
Output is correct |
25 |
Correct |
26 ms |
12148 KB |
Output is correct |
26 |
Correct |
26 ms |
12248 KB |
Output is correct |
27 |
Correct |
33 ms |
12856 KB |
Output is correct |
28 |
Correct |
28 ms |
12844 KB |
Output is correct |
29 |
Correct |
27 ms |
12860 KB |
Output is correct |
30 |
Correct |
28 ms |
12924 KB |
Output is correct |
31 |
Correct |
27 ms |
11632 KB |
Output is correct |
32 |
Correct |
25 ms |
11384 KB |
Output is correct |
33 |
Correct |
26 ms |
11900 KB |
Output is correct |
34 |
Correct |
25 ms |
11900 KB |
Output is correct |
35 |
Correct |
27 ms |
12948 KB |
Output is correct |
36 |
Correct |
28 ms |
12924 KB |
Output is correct |
37 |
Correct |
27 ms |
12876 KB |
Output is correct |
38 |
Correct |
27 ms |
12920 KB |
Output is correct |
39 |
Correct |
28 ms |
12928 KB |
Output is correct |
40 |
Correct |
27 ms |
12924 KB |
Output is correct |
41 |
Correct |
30 ms |
13368 KB |
Output is correct |
42 |
Correct |
28 ms |
13436 KB |
Output is correct |
43 |
Correct |
30 ms |
13544 KB |
Output is correct |
44 |
Correct |
28 ms |
13524 KB |
Output is correct |
45 |
Correct |
28 ms |
13432 KB |
Output is correct |
46 |
Correct |
30 ms |
13444 KB |
Output is correct |
47 |
Correct |
27 ms |
12840 KB |
Output is correct |
48 |
Correct |
27 ms |
12404 KB |
Output is correct |
49 |
Correct |
27 ms |
12384 KB |
Output is correct |
50 |
Correct |
31 ms |
12844 KB |
Output is correct |
51 |
Correct |
24 ms |
11636 KB |
Output is correct |
52 |
Correct |
24 ms |
11620 KB |
Output is correct |
53 |
Correct |
25 ms |
11644 KB |
Output is correct |
54 |
Correct |
25 ms |
11608 KB |
Output is correct |
55 |
Correct |
25 ms |
11664 KB |
Output is correct |
56 |
Correct |
25 ms |
11652 KB |
Output is correct |
57 |
Correct |
34 ms |
11572 KB |
Output is correct |
58 |
Correct |
26 ms |
11588 KB |
Output is correct |
59 |
Correct |
25 ms |
11640 KB |
Output is correct |
60 |
Correct |
26 ms |
11644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
11492 KB |
Output is correct |
2 |
Correct |
30 ms |
12668 KB |
Output is correct |
3 |
Correct |
1 ms |
1312 KB |
Output is correct |
4 |
Correct |
22 ms |
11392 KB |
Output is correct |
5 |
Correct |
31 ms |
14640 KB |
Output is correct |
6 |
Correct |
32 ms |
14680 KB |
Output is correct |
7 |
Correct |
26 ms |
13704 KB |
Output is correct |
8 |
Correct |
28 ms |
13696 KB |
Output is correct |
9 |
Correct |
38 ms |
14636 KB |
Output is correct |
10 |
Correct |
32 ms |
14648 KB |
Output is correct |
11 |
Correct |
31 ms |
14676 KB |
Output is correct |
12 |
Correct |
30 ms |
14712 KB |
Output is correct |
13 |
Correct |
39 ms |
14700 KB |
Output is correct |
14 |
Correct |
32 ms |
14964 KB |
Output is correct |
15 |
Correct |
30 ms |
14644 KB |
Output is correct |
16 |
Correct |
33 ms |
14720 KB |
Output is correct |
17 |
Correct |
28 ms |
14460 KB |
Output is correct |
18 |
Correct |
28 ms |
14384 KB |
Output is correct |
19 |
Correct |
32 ms |
14464 KB |
Output is correct |
20 |
Correct |
35 ms |
14264 KB |
Output is correct |
21 |
Correct |
28 ms |
14460 KB |
Output is correct |
22 |
Correct |
31 ms |
14396 KB |
Output is correct |
23 |
Correct |
24 ms |
11396 KB |
Output is correct |
24 |
Correct |
24 ms |
11388 KB |
Output is correct |
25 |
Correct |
26 ms |
12164 KB |
Output is correct |
26 |
Correct |
26 ms |
12392 KB |
Output is correct |
27 |
Correct |
27 ms |
12832 KB |
Output is correct |
28 |
Correct |
30 ms |
12920 KB |
Output is correct |
29 |
Correct |
28 ms |
12924 KB |
Output is correct |
30 |
Correct |
28 ms |
13164 KB |
Output is correct |
31 |
Correct |
25 ms |
11388 KB |
Output is correct |
32 |
Correct |
25 ms |
11388 KB |
Output is correct |
33 |
Correct |
26 ms |
12032 KB |
Output is correct |
34 |
Correct |
26 ms |
12152 KB |
Output is correct |
35 |
Correct |
28 ms |
13148 KB |
Output is correct |
36 |
Correct |
27 ms |
12924 KB |
Output is correct |
37 |
Correct |
27 ms |
12908 KB |
Output is correct |
38 |
Correct |
27 ms |
12956 KB |
Output is correct |
39 |
Correct |
27 ms |
12752 KB |
Output is correct |
40 |
Correct |
27 ms |
12984 KB |
Output is correct |
41 |
Correct |
28 ms |
13680 KB |
Output is correct |
42 |
Correct |
27 ms |
13396 KB |
Output is correct |
43 |
Correct |
28 ms |
13440 KB |
Output is correct |
44 |
Correct |
34 ms |
13560 KB |
Output is correct |
45 |
Correct |
32 ms |
13508 KB |
Output is correct |
46 |
Correct |
33 ms |
13440 KB |
Output is correct |
47 |
Correct |
27 ms |
12392 KB |
Output is correct |
48 |
Correct |
27 ms |
12408 KB |
Output is correct |
49 |
Correct |
29 ms |
12404 KB |
Output is correct |
50 |
Correct |
27 ms |
12668 KB |
Output is correct |
51 |
Correct |
26 ms |
11648 KB |
Output is correct |
52 |
Correct |
25 ms |
11652 KB |
Output is correct |
53 |
Correct |
25 ms |
11888 KB |
Output is correct |
54 |
Correct |
30 ms |
11636 KB |
Output is correct |
55 |
Correct |
24 ms |
11632 KB |
Output is correct |
56 |
Correct |
26 ms |
11668 KB |
Output is correct |
57 |
Correct |
25 ms |
11632 KB |
Output is correct |
58 |
Correct |
25 ms |
11640 KB |
Output is correct |
59 |
Correct |
26 ms |
11644 KB |
Output is correct |
60 |
Correct |
30 ms |
11644 KB |
Output is correct |