#include<bits/stdc++.h>
#include "Anthony.h"
#define ll long long
const int inf=1e9;
using namespace std;
int d[20005],s[6]={0,0,1,0,1,1};
vector<int>g[20005],ans;
queue<int>q;
void dfs(int nod,int t,vector<int>&u,vector<int>&v)
{
for(auto it:g[nod]){
int nod2=u[it]^v[it]^nod;
if (nod2!=t){
ans[it]=s[d[nod]];
d[nod2]=g[nod2].size()>2?(ans[it]^1)<<1:(d[nod]+1)%6;
dfs(nod2,nod,u,v);
}
}
}
vector<int> Mark(int n,int m,int a,int b,vector<int>u,vector<int>v)
{
ans.resize(m);
int i;
for(i=0;i<m;i++){
g[u[i]].push_back(i);
g[v[i]].push_back(i);
}
d[0]=1;
if (a>2){
q.push(0);
while(!q.empty()){
int nod=q.front();
q.pop();
for(auto it:g[nod]){
int nod2=u[it]^v[it]^nod;
if (d[nod2]==0){
d[nod2]=d[nod]+1;
q.push(nod2);
}
if (d[nod2]==d[nod] || d[nod2]==d[nod]+1)
ans[it]=d[nod]%3;
}
}
}
else{
dfs(0,-1,u,v);
}
return ans;
}
#include<bits/stdc++.h>
#include "Catherine.h"
using namespace std;
int a,b,pre=-1;
int s[6]={0,0,1,0,1,1};
bool ok=0;
vector<int>g;
void Init(int A,int B)
{
a=A;
b=B;
}
int Move(vector<int>v)
{
if (a>2){
if (~pre)
v[pre]++;
int i;
for(i=0;i<3;i++)
if (v[i] && v[(i+1)%3])
return pre=i;
for(i=0;i<3;i++)
if (v[i])
return pre=i;
}
else{
if (ok){
if (v[0]+v[1]>1)
v[pre]++;
return pre=(v[0]==1)^1;
}
if (!~pre){
if (v[0]+v[1]!=2){
ok=1;
return pre=(v[0]==1)^1;
}
pre=(v[0]>0)^1;
g.push_back((v[0]>1)^1);
g.push_back(pre);
return pre;
}
if (v[0]+v[1]==0){
ok=1;
return -1;
}
if (v[0]+v[1]>1){
ok=1;
return !v[pre]?-1:pre^=1;
}
g.push_back((v[0]==1)^1);
if (g.size()==5){
int i;
for(i=0;i<6;i++){
ok=1;
int j;
for(j=0;j<5;j++)
ok&=s[(i+j)%6]==g[j];
if (ok)
return -1;
}
ok=1;
}
return pre=(v[0]==1)^1;
}
return -2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
15820 KB |
Output is correct |
2 |
Correct |
1 ms |
1008 KB |
Output is correct |
3 |
Correct |
36 ms |
15200 KB |
Output is correct |
4 |
Correct |
57 ms |
16900 KB |
Output is correct |
5 |
Correct |
62 ms |
17000 KB |
Output is correct |
6 |
Correct |
44 ms |
15596 KB |
Output is correct |
7 |
Correct |
43 ms |
15500 KB |
Output is correct |
8 |
Correct |
51 ms |
16300 KB |
Output is correct |
9 |
Correct |
52 ms |
16300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
15820 KB |
Output is correct |
2 |
Correct |
1 ms |
1008 KB |
Output is correct |
3 |
Correct |
36 ms |
15200 KB |
Output is correct |
4 |
Correct |
57 ms |
16900 KB |
Output is correct |
5 |
Correct |
62 ms |
17000 KB |
Output is correct |
6 |
Correct |
44 ms |
15596 KB |
Output is correct |
7 |
Correct |
43 ms |
15500 KB |
Output is correct |
8 |
Correct |
51 ms |
16300 KB |
Output is correct |
9 |
Correct |
52 ms |
16300 KB |
Output is correct |
10 |
Correct |
41 ms |
13592 KB |
Output is correct |
11 |
Correct |
40 ms |
13644 KB |
Output is correct |
12 |
Correct |
40 ms |
13684 KB |
Output is correct |
13 |
Correct |
41 ms |
13676 KB |
Output is correct |
14 |
Correct |
42 ms |
13892 KB |
Output is correct |
15 |
Correct |
47 ms |
14220 KB |
Output is correct |
16 |
Correct |
51 ms |
16596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
13448 KB |
Output is correct |
2 |
Correct |
1 ms |
1008 KB |
Output is correct |
3 |
Correct |
37 ms |
12896 KB |
Output is correct |
4 |
Correct |
54 ms |
14772 KB |
Output is correct |
5 |
Correct |
54 ms |
14756 KB |
Output is correct |
6 |
Correct |
42 ms |
13400 KB |
Output is correct |
7 |
Correct |
41 ms |
13424 KB |
Output is correct |
8 |
Correct |
52 ms |
14044 KB |
Output is correct |
9 |
Correct |
49 ms |
14080 KB |
Output is correct |
10 |
Correct |
45 ms |
13828 KB |
Output is correct |
11 |
Correct |
49 ms |
13956 KB |
Output is correct |
12 |
Correct |
49 ms |
13828 KB |
Output is correct |
13 |
Correct |
47 ms |
13860 KB |
Output is correct |
14 |
Correct |
53 ms |
13964 KB |
Output is correct |
15 |
Correct |
57 ms |
14108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
13448 KB |
Output is correct |
2 |
Correct |
1 ms |
1008 KB |
Output is correct |
3 |
Correct |
37 ms |
12896 KB |
Output is correct |
4 |
Correct |
54 ms |
14772 KB |
Output is correct |
5 |
Correct |
54 ms |
14756 KB |
Output is correct |
6 |
Correct |
42 ms |
13400 KB |
Output is correct |
7 |
Correct |
41 ms |
13424 KB |
Output is correct |
8 |
Correct |
52 ms |
14044 KB |
Output is correct |
9 |
Correct |
49 ms |
14080 KB |
Output is correct |
10 |
Correct |
45 ms |
13828 KB |
Output is correct |
11 |
Correct |
49 ms |
13956 KB |
Output is correct |
12 |
Correct |
49 ms |
13828 KB |
Output is correct |
13 |
Correct |
47 ms |
13860 KB |
Output is correct |
14 |
Correct |
53 ms |
13964 KB |
Output is correct |
15 |
Correct |
57 ms |
14108 KB |
Output is correct |
16 |
Correct |
40 ms |
11836 KB |
Output is correct |
17 |
Correct |
39 ms |
11920 KB |
Output is correct |
18 |
Correct |
39 ms |
11740 KB |
Output is correct |
19 |
Correct |
39 ms |
11772 KB |
Output is correct |
20 |
Correct |
50 ms |
12400 KB |
Output is correct |
21 |
Correct |
47 ms |
12164 KB |
Output is correct |
22 |
Correct |
48 ms |
14324 KB |
Output is correct |
23 |
Correct |
41 ms |
11848 KB |
Output is correct |
24 |
Correct |
39 ms |
11920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1268 KB |
Output is correct |
2 |
Correct |
1 ms |
1004 KB |
Output is correct |
3 |
Correct |
2 ms |
1272 KB |
Output is correct |
4 |
Correct |
2 ms |
1408 KB |
Output is correct |
5 |
Correct |
2 ms |
1396 KB |
Output is correct |
6 |
Correct |
2 ms |
1328 KB |
Output is correct |
7 |
Correct |
2 ms |
1396 KB |
Output is correct |
8 |
Correct |
2 ms |
1412 KB |
Output is correct |
9 |
Correct |
3 ms |
1408 KB |
Output is correct |
10 |
Correct |
2 ms |
1408 KB |
Output is correct |
11 |
Correct |
2 ms |
1408 KB |
Output is correct |
12 |
Correct |
2 ms |
1268 KB |
Output is correct |
13 |
Correct |
3 ms |
1276 KB |
Output is correct |
14 |
Correct |
2 ms |
1396 KB |
Output is correct |
15 |
Correct |
2 ms |
1392 KB |
Output is correct |
16 |
Correct |
3 ms |
1268 KB |
Output is correct |
17 |
Correct |
2 ms |
1272 KB |
Output is correct |
18 |
Correct |
2 ms |
1264 KB |
Output is correct |
19 |
Correct |
2 ms |
1268 KB |
Output is correct |
20 |
Correct |
2 ms |
1272 KB |
Output is correct |
21 |
Correct |
2 ms |
1268 KB |
Output is correct |
22 |
Correct |
2 ms |
1272 KB |
Output is correct |
23 |
Correct |
2 ms |
1276 KB |
Output is correct |
24 |
Correct |
2 ms |
1268 KB |
Output is correct |
25 |
Correct |
2 ms |
1320 KB |
Output is correct |
26 |
Correct |
2 ms |
1268 KB |
Output is correct |
27 |
Correct |
2 ms |
1384 KB |
Output is correct |
28 |
Correct |
2 ms |
1268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
11552 KB |
Output is correct |
2 |
Correct |
49 ms |
12888 KB |
Output is correct |
3 |
Correct |
1 ms |
1008 KB |
Output is correct |
4 |
Correct |
34 ms |
11444 KB |
Output is correct |
5 |
Correct |
49 ms |
14636 KB |
Output is correct |
6 |
Correct |
50 ms |
14604 KB |
Output is correct |
7 |
Correct |
48 ms |
13808 KB |
Output is correct |
8 |
Correct |
48 ms |
13832 KB |
Output is correct |
9 |
Correct |
50 ms |
14756 KB |
Output is correct |
10 |
Correct |
52 ms |
14704 KB |
Output is correct |
11 |
Correct |
49 ms |
14636 KB |
Output is correct |
12 |
Correct |
52 ms |
14704 KB |
Output is correct |
13 |
Correct |
50 ms |
14604 KB |
Output is correct |
14 |
Correct |
52 ms |
14580 KB |
Output is correct |
15 |
Correct |
50 ms |
14608 KB |
Output is correct |
16 |
Correct |
50 ms |
14540 KB |
Output is correct |
17 |
Correct |
52 ms |
14324 KB |
Output is correct |
18 |
Correct |
47 ms |
14320 KB |
Output is correct |
19 |
Correct |
51 ms |
14260 KB |
Output is correct |
20 |
Correct |
47 ms |
14320 KB |
Output is correct |
21 |
Correct |
46 ms |
14376 KB |
Output is correct |
22 |
Correct |
50 ms |
14316 KB |
Output is correct |
23 |
Correct |
40 ms |
11456 KB |
Output is correct |
24 |
Correct |
42 ms |
11504 KB |
Output is correct |
25 |
Correct |
39 ms |
12180 KB |
Output is correct |
26 |
Correct |
39 ms |
12148 KB |
Output is correct |
27 |
Correct |
49 ms |
13020 KB |
Output is correct |
28 |
Correct |
48 ms |
13028 KB |
Output is correct |
29 |
Correct |
44 ms |
13088 KB |
Output is correct |
30 |
Correct |
45 ms |
13020 KB |
Output is correct |
31 |
Correct |
38 ms |
11564 KB |
Output is correct |
32 |
Correct |
40 ms |
11500 KB |
Output is correct |
33 |
Correct |
39 ms |
12016 KB |
Output is correct |
34 |
Correct |
40 ms |
11940 KB |
Output is correct |
35 |
Correct |
45 ms |
12800 KB |
Output is correct |
36 |
Correct |
43 ms |
12784 KB |
Output is correct |
37 |
Correct |
44 ms |
12832 KB |
Output is correct |
38 |
Correct |
48 ms |
12816 KB |
Output is correct |
39 |
Correct |
49 ms |
12748 KB |
Output is correct |
40 |
Correct |
45 ms |
12744 KB |
Output is correct |
41 |
Correct |
47 ms |
13668 KB |
Output is correct |
42 |
Correct |
46 ms |
13548 KB |
Output is correct |
43 |
Correct |
46 ms |
13644 KB |
Output is correct |
44 |
Correct |
49 ms |
13672 KB |
Output is correct |
45 |
Correct |
52 ms |
13724 KB |
Output is correct |
46 |
Correct |
46 ms |
13692 KB |
Output is correct |
47 |
Correct |
43 ms |
12752 KB |
Output is correct |
48 |
Correct |
42 ms |
12752 KB |
Output is correct |
49 |
Correct |
44 ms |
12596 KB |
Output is correct |
50 |
Correct |
46 ms |
12800 KB |
Output is correct |
51 |
Correct |
40 ms |
11844 KB |
Output is correct |
52 |
Correct |
43 ms |
11956 KB |
Output is correct |
53 |
Correct |
39 ms |
11780 KB |
Output is correct |
54 |
Correct |
40 ms |
11768 KB |
Output is correct |
55 |
Correct |
43 ms |
11868 KB |
Output is correct |
56 |
Correct |
39 ms |
11876 KB |
Output is correct |
57 |
Correct |
44 ms |
11748 KB |
Output is correct |
58 |
Correct |
47 ms |
11652 KB |
Output is correct |
59 |
Correct |
40 ms |
11860 KB |
Output is correct |
60 |
Correct |
40 ms |
11928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
11504 KB |
Output is correct |
2 |
Correct |
50 ms |
12836 KB |
Output is correct |
3 |
Correct |
1 ms |
1008 KB |
Output is correct |
4 |
Correct |
34 ms |
11328 KB |
Output is correct |
5 |
Correct |
50 ms |
14668 KB |
Output is correct |
6 |
Correct |
50 ms |
14620 KB |
Output is correct |
7 |
Correct |
41 ms |
13736 KB |
Output is correct |
8 |
Correct |
41 ms |
13832 KB |
Output is correct |
9 |
Correct |
49 ms |
14636 KB |
Output is correct |
10 |
Correct |
50 ms |
14552 KB |
Output is correct |
11 |
Correct |
53 ms |
14644 KB |
Output is correct |
12 |
Correct |
52 ms |
14628 KB |
Output is correct |
13 |
Correct |
50 ms |
14600 KB |
Output is correct |
14 |
Correct |
50 ms |
14584 KB |
Output is correct |
15 |
Correct |
52 ms |
14608 KB |
Output is correct |
16 |
Correct |
51 ms |
14588 KB |
Output is correct |
17 |
Correct |
47 ms |
14308 KB |
Output is correct |
18 |
Correct |
47 ms |
14440 KB |
Output is correct |
19 |
Correct |
46 ms |
14364 KB |
Output is correct |
20 |
Correct |
48 ms |
14288 KB |
Output is correct |
21 |
Correct |
47 ms |
14388 KB |
Output is correct |
22 |
Correct |
46 ms |
14368 KB |
Output is correct |
23 |
Correct |
39 ms |
11476 KB |
Output is correct |
24 |
Correct |
38 ms |
11556 KB |
Output is correct |
25 |
Correct |
41 ms |
12020 KB |
Output is correct |
26 |
Correct |
40 ms |
12044 KB |
Output is correct |
27 |
Correct |
47 ms |
13064 KB |
Output is correct |
28 |
Correct |
43 ms |
13056 KB |
Output is correct |
29 |
Correct |
44 ms |
13128 KB |
Output is correct |
30 |
Correct |
45 ms |
13052 KB |
Output is correct |
31 |
Correct |
38 ms |
11488 KB |
Output is correct |
32 |
Correct |
40 ms |
11620 KB |
Output is correct |
33 |
Correct |
41 ms |
11996 KB |
Output is correct |
34 |
Correct |
39 ms |
12148 KB |
Output is correct |
35 |
Correct |
44 ms |
12808 KB |
Output is correct |
36 |
Correct |
44 ms |
12768 KB |
Output is correct |
37 |
Correct |
44 ms |
12940 KB |
Output is correct |
38 |
Correct |
46 ms |
12856 KB |
Output is correct |
39 |
Correct |
44 ms |
12800 KB |
Output is correct |
40 |
Correct |
44 ms |
12892 KB |
Output is correct |
41 |
Correct |
46 ms |
13580 KB |
Output is correct |
42 |
Correct |
48 ms |
13664 KB |
Output is correct |
43 |
Correct |
47 ms |
13656 KB |
Output is correct |
44 |
Correct |
49 ms |
13688 KB |
Output is correct |
45 |
Correct |
47 ms |
13680 KB |
Output is correct |
46 |
Correct |
46 ms |
13632 KB |
Output is correct |
47 |
Correct |
42 ms |
12588 KB |
Output is correct |
48 |
Correct |
43 ms |
12724 KB |
Output is correct |
49 |
Correct |
43 ms |
12692 KB |
Output is correct |
50 |
Correct |
45 ms |
12744 KB |
Output is correct |
51 |
Correct |
39 ms |
11812 KB |
Output is correct |
52 |
Correct |
39 ms |
11716 KB |
Output is correct |
53 |
Correct |
39 ms |
11796 KB |
Output is correct |
54 |
Correct |
39 ms |
11820 KB |
Output is correct |
55 |
Correct |
39 ms |
11808 KB |
Output is correct |
56 |
Correct |
39 ms |
11756 KB |
Output is correct |
57 |
Correct |
43 ms |
11808 KB |
Output is correct |
58 |
Correct |
40 ms |
11696 KB |
Output is correct |
59 |
Correct |
40 ms |
11864 KB |
Output is correct |
60 |
Correct |
39 ms |
11848 KB |
Output is correct |