#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
const int MN = 2e4+5;
int n, i, dep[MN], par[MN], col[MN], vs[MN], hm[MN];
vi ans; vector<pii> adj[MN];
queue<int> q;
vi Mark(int N,int M,int A,int B,vi U,vi V){
ans.resize(M);
for(i=0;i<M;i++){
adj[U[i]].pb({V[i],i});
adj[V[i]].pb({U[i],i});
}
if(A>=3){
vs[0] = 1; q.push(0);
while(q.size()){
int x = q.front(); q.pop();
for(auto v : adj[x]){
if(!vs[v.first]){
vs[v.first] = 1;
dep[v.first] = dep[x]+1;
ans[v.second] = dep[x]%3;
q.push(v.first);
}
else ans[v.second]=min(dep[x],dep[v.first])%3;
}
}
return ans;
}
else{
int msk[]={0,0,1,0,1,1};
q.push(0);
while(q.size()){
int x = q.front(); q.pop();
if(x&&adj[x].size()==2){
hm[x] = 1;
if(hm[par[x]]) dep[x]=(dep[par[x]]+1)%6;
else if(col[x]==0) dep[x]=0;
else dep[x]=2;
for(auto v : adj[x]){
if(v.first==par[x]) continue;
ans[v.second]=col[v.first]=msk[(dep[x]+1)%6];
par[v.first]=x;
q.push(v.first);
}
}
else{
for(auto v : adj[x]){
if(v.first==par[x]) continue;
ans[v.second]=col[v.first]=!col[x];
par[v.first]=x;
q.push(v.first);
}
}
}
return ans;
}
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
int lst=-1, sub, ok, pat[]={0,0,1,0,1,1};
vi guess;
void Init(int A,int B){
if(A>=3) sub=1;
else sub=2;
}
bool match(){
for(int i=0;i<6;i++){
int tmp = 0;
for(int j=0;j<guess.size();j++){
if(guess[j]!=pat[(i+j)%6]){tmp=1;break;}
}
if(!tmp) return 1;
}
return 0;
}
int Move(vi cnt){
if(sub==1){
for(int i=0;i<3;i++){
if(cnt[i]&&!cnt[(i+2)%3]) return i;
}
}
else{
int c=0;
if(lst!=-1) cnt[lst]++;
for(auto v : cnt) c += v;
if(c!=2) ok=1;
if(ok){
if(c==2){
cnt[lst]--;
if(cnt[0]){lst=0;return lst;}
else{lst=1;return lst;}
}
if(lst==-1){
if(cnt[0]==1){lst=0; return 0;}
else{lst=1; return 1;}
}
if(cnt[0]==1&&cnt[1]==1){lst=!lst;return lst;}
if(cnt[lst]==1) return -1;
else{lst=!lst; return lst;}
}
else{
if(lst==-1){
if(cnt[0]){
guess.pb(0);
if(cnt[1]){guess.pb(1); lst=1;}
else{guess.pb(0); lst=0;}
}
else{
guess.pb(1); guess.pb(1);
lst = 1;
}
return lst;
}
else{
cnt[lst]--;
int ot=0;
if(cnt[1]) ot=1;
guess.pb(ot);
bool d1 = match();
reverse(guess.begin(),guess.end());
bool d2 = match();
reverse(guess.begin(),guess.end());
if(d1!=d2){
ok = 1;
if(d1) return -1;
else{lst = ot; return ot;}
}
lst = ot;
return ot;
}
}
}
}
Compilation message
Catherine.cpp: In function 'bool match()':
Catherine.cpp:20:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<guess.size();j++){
~^~~~~~~~~~~~~
Catherine.cpp: In function 'int Move(vi)':
Catherine.cpp:85:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
15844 KB |
Output is correct |
2 |
Correct |
10 ms |
1536 KB |
Output is correct |
3 |
Correct |
57 ms |
15228 KB |
Output is correct |
4 |
Correct |
84 ms |
16972 KB |
Output is correct |
5 |
Correct |
98 ms |
16852 KB |
Output is correct |
6 |
Correct |
69 ms |
15708 KB |
Output is correct |
7 |
Correct |
63 ms |
15604 KB |
Output is correct |
8 |
Correct |
76 ms |
16252 KB |
Output is correct |
9 |
Correct |
71 ms |
16432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
15844 KB |
Output is correct |
2 |
Correct |
10 ms |
1536 KB |
Output is correct |
3 |
Correct |
57 ms |
15228 KB |
Output is correct |
4 |
Correct |
84 ms |
16972 KB |
Output is correct |
5 |
Correct |
98 ms |
16852 KB |
Output is correct |
6 |
Correct |
69 ms |
15708 KB |
Output is correct |
7 |
Correct |
63 ms |
15604 KB |
Output is correct |
8 |
Correct |
76 ms |
16252 KB |
Output is correct |
9 |
Correct |
71 ms |
16432 KB |
Output is correct |
10 |
Correct |
60 ms |
13732 KB |
Output is correct |
11 |
Correct |
70 ms |
13704 KB |
Output is correct |
12 |
Correct |
52 ms |
13712 KB |
Output is correct |
13 |
Correct |
67 ms |
13556 KB |
Output is correct |
14 |
Correct |
54 ms |
13956 KB |
Output is correct |
15 |
Correct |
65 ms |
14256 KB |
Output is correct |
16 |
Correct |
64 ms |
16380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
13544 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
54 ms |
13064 KB |
Output is correct |
4 |
Correct |
69 ms |
14708 KB |
Output is correct |
5 |
Correct |
93 ms |
14696 KB |
Output is correct |
6 |
Correct |
56 ms |
13480 KB |
Output is correct |
7 |
Correct |
55 ms |
13516 KB |
Output is correct |
8 |
Correct |
66 ms |
14204 KB |
Output is correct |
9 |
Correct |
74 ms |
14180 KB |
Output is correct |
10 |
Correct |
65 ms |
13852 KB |
Output is correct |
11 |
Correct |
56 ms |
13812 KB |
Output is correct |
12 |
Correct |
64 ms |
13956 KB |
Output is correct |
13 |
Correct |
60 ms |
13820 KB |
Output is correct |
14 |
Correct |
75 ms |
14216 KB |
Output is correct |
15 |
Correct |
62 ms |
14080 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
13544 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
54 ms |
13064 KB |
Output is correct |
4 |
Correct |
69 ms |
14708 KB |
Output is correct |
5 |
Correct |
93 ms |
14696 KB |
Output is correct |
6 |
Correct |
56 ms |
13480 KB |
Output is correct |
7 |
Correct |
55 ms |
13516 KB |
Output is correct |
8 |
Correct |
66 ms |
14204 KB |
Output is correct |
9 |
Correct |
74 ms |
14180 KB |
Output is correct |
10 |
Correct |
65 ms |
13852 KB |
Output is correct |
11 |
Correct |
56 ms |
13812 KB |
Output is correct |
12 |
Correct |
64 ms |
13956 KB |
Output is correct |
13 |
Correct |
60 ms |
13820 KB |
Output is correct |
14 |
Correct |
75 ms |
14216 KB |
Output is correct |
15 |
Correct |
62 ms |
14080 KB |
Output is correct |
16 |
Correct |
48 ms |
11752 KB |
Output is correct |
17 |
Correct |
50 ms |
11904 KB |
Output is correct |
18 |
Correct |
52 ms |
11884 KB |
Output is correct |
19 |
Correct |
51 ms |
11768 KB |
Output is correct |
20 |
Correct |
61 ms |
12632 KB |
Output is correct |
21 |
Correct |
56 ms |
12160 KB |
Output is correct |
22 |
Correct |
64 ms |
14196 KB |
Output is correct |
23 |
Correct |
63 ms |
11876 KB |
Output is correct |
24 |
Correct |
65 ms |
11980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
1792 KB |
Output is correct |
2 |
Correct |
11 ms |
1536 KB |
Output is correct |
3 |
Correct |
10 ms |
1792 KB |
Output is correct |
4 |
Correct |
10 ms |
1792 KB |
Output is correct |
5 |
Correct |
11 ms |
1792 KB |
Output is correct |
6 |
Correct |
11 ms |
1792 KB |
Output is correct |
7 |
Correct |
10 ms |
1792 KB |
Output is correct |
8 |
Correct |
10 ms |
1632 KB |
Output is correct |
9 |
Correct |
10 ms |
1792 KB |
Output is correct |
10 |
Correct |
10 ms |
1792 KB |
Output is correct |
11 |
Correct |
12 ms |
1792 KB |
Output is correct |
12 |
Correct |
12 ms |
1792 KB |
Output is correct |
13 |
Correct |
11 ms |
1792 KB |
Output is correct |
14 |
Correct |
10 ms |
1792 KB |
Output is correct |
15 |
Correct |
10 ms |
1792 KB |
Output is correct |
16 |
Correct |
12 ms |
1792 KB |
Output is correct |
17 |
Correct |
10 ms |
1792 KB |
Output is correct |
18 |
Correct |
11 ms |
1792 KB |
Output is correct |
19 |
Correct |
11 ms |
1792 KB |
Output is correct |
20 |
Correct |
10 ms |
1792 KB |
Output is correct |
21 |
Correct |
10 ms |
1792 KB |
Output is correct |
22 |
Correct |
12 ms |
1792 KB |
Output is correct |
23 |
Correct |
10 ms |
1792 KB |
Output is correct |
24 |
Correct |
11 ms |
1792 KB |
Output is correct |
25 |
Correct |
11 ms |
1792 KB |
Output is correct |
26 |
Correct |
10 ms |
1792 KB |
Output is correct |
27 |
Correct |
10 ms |
1792 KB |
Output is correct |
28 |
Correct |
7 ms |
1792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
11676 KB |
Output is correct |
2 |
Correct |
65 ms |
12096 KB |
Output is correct |
3 |
Correct |
10 ms |
1536 KB |
Output is correct |
4 |
Correct |
48 ms |
11384 KB |
Output is correct |
5 |
Correct |
78 ms |
12916 KB |
Output is correct |
6 |
Correct |
72 ms |
12784 KB |
Output is correct |
7 |
Correct |
52 ms |
12028 KB |
Output is correct |
8 |
Correct |
55 ms |
11876 KB |
Output is correct |
9 |
Correct |
69 ms |
12856 KB |
Output is correct |
10 |
Correct |
73 ms |
12788 KB |
Output is correct |
11 |
Correct |
63 ms |
12880 KB |
Output is correct |
12 |
Correct |
73 ms |
12796 KB |
Output is correct |
13 |
Correct |
70 ms |
12800 KB |
Output is correct |
14 |
Correct |
78 ms |
12860 KB |
Output is correct |
15 |
Correct |
72 ms |
12916 KB |
Output is correct |
16 |
Correct |
71 ms |
12792 KB |
Output is correct |
17 |
Correct |
68 ms |
12540 KB |
Output is correct |
18 |
Correct |
77 ms |
12372 KB |
Output is correct |
19 |
Correct |
78 ms |
12524 KB |
Output is correct |
20 |
Correct |
68 ms |
12380 KB |
Output is correct |
21 |
Correct |
74 ms |
12516 KB |
Output is correct |
22 |
Correct |
66 ms |
12532 KB |
Output is correct |
23 |
Correct |
71 ms |
11612 KB |
Output is correct |
24 |
Correct |
60 ms |
11736 KB |
Output is correct |
25 |
Correct |
57 ms |
11904 KB |
Output is correct |
26 |
Correct |
61 ms |
11764 KB |
Output is correct |
27 |
Correct |
74 ms |
12256 KB |
Output is correct |
28 |
Correct |
71 ms |
12300 KB |
Output is correct |
29 |
Correct |
69 ms |
12268 KB |
Output is correct |
30 |
Correct |
70 ms |
12276 KB |
Output is correct |
31 |
Correct |
57 ms |
11740 KB |
Output is correct |
32 |
Correct |
56 ms |
11756 KB |
Output is correct |
33 |
Correct |
60 ms |
11772 KB |
Output is correct |
34 |
Correct |
55 ms |
11868 KB |
Output is correct |
35 |
Correct |
66 ms |
12304 KB |
Output is correct |
36 |
Correct |
63 ms |
12220 KB |
Output is correct |
37 |
Correct |
56 ms |
12292 KB |
Output is correct |
38 |
Correct |
64 ms |
12316 KB |
Output is correct |
39 |
Correct |
59 ms |
12764 KB |
Output is correct |
40 |
Correct |
65 ms |
12756 KB |
Output is correct |
41 |
Correct |
80 ms |
12772 KB |
Output is correct |
42 |
Correct |
65 ms |
13076 KB |
Output is correct |
43 |
Correct |
69 ms |
12516 KB |
Output is correct |
44 |
Correct |
67 ms |
12644 KB |
Output is correct |
45 |
Correct |
59 ms |
12548 KB |
Output is correct |
46 |
Correct |
70 ms |
12548 KB |
Output is correct |
47 |
Correct |
80 ms |
12596 KB |
Output is correct |
48 |
Correct |
75 ms |
12616 KB |
Output is correct |
49 |
Correct |
80 ms |
12472 KB |
Output is correct |
50 |
Correct |
79 ms |
12696 KB |
Output is correct |
51 |
Correct |
64 ms |
12360 KB |
Output is correct |
52 |
Correct |
53 ms |
12420 KB |
Output is correct |
53 |
Correct |
68 ms |
12352 KB |
Output is correct |
54 |
Correct |
58 ms |
12372 KB |
Output is correct |
55 |
Correct |
62 ms |
12236 KB |
Output is correct |
56 |
Correct |
56 ms |
12252 KB |
Output is correct |
57 |
Correct |
57 ms |
12304 KB |
Output is correct |
58 |
Correct |
65 ms |
12332 KB |
Output is correct |
59 |
Correct |
63 ms |
12300 KB |
Output is correct |
60 |
Correct |
70 ms |
12320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
12120 KB |
Output is correct |
2 |
Correct |
64 ms |
12500 KB |
Output is correct |
3 |
Correct |
10 ms |
1792 KB |
Output is correct |
4 |
Correct |
46 ms |
11840 KB |
Output is correct |
5 |
Correct |
69 ms |
13360 KB |
Output is correct |
6 |
Correct |
79 ms |
13260 KB |
Output is correct |
7 |
Correct |
61 ms |
12580 KB |
Output is correct |
8 |
Correct |
53 ms |
12576 KB |
Output is correct |
9 |
Correct |
72 ms |
13300 KB |
Output is correct |
10 |
Correct |
83 ms |
13364 KB |
Output is correct |
11 |
Correct |
66 ms |
13320 KB |
Output is correct |
12 |
Correct |
80 ms |
13388 KB |
Output is correct |
13 |
Correct |
78 ms |
13416 KB |
Output is correct |
14 |
Correct |
88 ms |
13264 KB |
Output is correct |
15 |
Correct |
74 ms |
13396 KB |
Output is correct |
16 |
Correct |
72 ms |
13252 KB |
Output is correct |
17 |
Correct |
67 ms |
13004 KB |
Output is correct |
18 |
Correct |
69 ms |
13004 KB |
Output is correct |
19 |
Correct |
73 ms |
12964 KB |
Output is correct |
20 |
Correct |
72 ms |
12956 KB |
Output is correct |
21 |
Correct |
61 ms |
12944 KB |
Output is correct |
22 |
Correct |
68 ms |
13004 KB |
Output is correct |
23 |
Correct |
70 ms |
12104 KB |
Output is correct |
24 |
Correct |
59 ms |
12136 KB |
Output is correct |
25 |
Correct |
61 ms |
12252 KB |
Output is correct |
26 |
Correct |
66 ms |
12360 KB |
Output is correct |
27 |
Correct |
64 ms |
12724 KB |
Output is correct |
28 |
Correct |
61 ms |
12628 KB |
Output is correct |
29 |
Correct |
62 ms |
12620 KB |
Output is correct |
30 |
Correct |
61 ms |
12712 KB |
Output is correct |
31 |
Correct |
55 ms |
12116 KB |
Output is correct |
32 |
Correct |
60 ms |
12236 KB |
Output is correct |
33 |
Correct |
59 ms |
12244 KB |
Output is correct |
34 |
Correct |
63 ms |
12396 KB |
Output is correct |
35 |
Correct |
57 ms |
12628 KB |
Output is correct |
36 |
Correct |
76 ms |
12732 KB |
Output is correct |
37 |
Correct |
77 ms |
12740 KB |
Output is correct |
38 |
Correct |
64 ms |
12484 KB |
Output is correct |
39 |
Correct |
73 ms |
12748 KB |
Output is correct |
40 |
Correct |
55 ms |
12716 KB |
Output is correct |
41 |
Correct |
62 ms |
12836 KB |
Output is correct |
42 |
Correct |
74 ms |
12756 KB |
Output is correct |
43 |
Correct |
70 ms |
12916 KB |
Output is correct |
44 |
Correct |
68 ms |
12748 KB |
Output is correct |
45 |
Correct |
76 ms |
12884 KB |
Output is correct |
46 |
Correct |
67 ms |
12748 KB |
Output is correct |
47 |
Correct |
72 ms |
12492 KB |
Output is correct |
48 |
Correct |
62 ms |
12500 KB |
Output is correct |
49 |
Correct |
58 ms |
12464 KB |
Output is correct |
50 |
Correct |
67 ms |
12592 KB |
Output is correct |
51 |
Correct |
63 ms |
12292 KB |
Output is correct |
52 |
Correct |
57 ms |
12328 KB |
Output is correct |
53 |
Correct |
53 ms |
12244 KB |
Output is correct |
54 |
Correct |
56 ms |
12372 KB |
Output is correct |
55 |
Correct |
56 ms |
11872 KB |
Output is correct |
56 |
Correct |
55 ms |
11972 KB |
Output is correct |
57 |
Correct |
51 ms |
11972 KB |
Output is correct |
58 |
Correct |
60 ms |
11852 KB |
Output is correct |
59 |
Correct |
53 ms |
11880 KB |
Output is correct |
60 |
Correct |
64 ms |
11848 KB |
Output is correct |