#include "Anthony.h"
#include <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
using namespace std;
vector<pair<int,int>> adj[20000];
int dist[20000];
std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) {
vector<int> X(M,-1);
queue<pair<int,int>> Q;
memset(dist,-1,sizeof(dist));
for(int i=0;i<M;i++) {
adj[U[i]].emplace_back(V[i],i);
adj[V[i]].emplace_back(U[i],i);
}
dist[0]=0;
for(auto[n,t]: adj[0]) {
dist[n]=1; X[t]=0;
Q.emplace(n,t);
}
while(!Q.empty()) {
auto[c,p]=Q.front();
Q.pop();
for(auto[n,t]: adj[c]) {
if(dist[n]==-1) {
dist[n]=dist[c]+1;
if(A==2) {
if(X[p]>1) {
if(adj[c].size()==2) X[t]=(X[p]-1)%6+2;
else X[t]=!(X[p]==3 || X[p]==6 || X[p]==7);
}
else {
if(adj[c].size()==2) X[t]=X[p]+3;
else X[t]=X[p]^1;
}
}
else X[t]=min(dist[c],dist[n])%3;
Q.emplace(n,t);
}
else if(X[t]==-1) X[t]=min(dist[c],dist[n])%3;
}
}
if(A==2) for(auto &p: X) p=p==1 || p==3 || p==6 || p==7;
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
using namespace std;
int A, r;
bool d;
string s;
void Init(int A, int B) {
::A=A;
r=-1; d=false; s="";
}
int Move(std::vector<int> y) {
if(r!=-1) y[r]++;
if(A==2) {
if(d) {
if(y[0]+y[1]==2) {
y[r]--;
for(int i=0;i<2;i++) if(y[i]) return r=i;
}
for(int i=0;i<2;i++) if(y[i]==1) return r=i;
}
else {
if(y[0]+y[1]>2) {
d=true;
if(r!=-1 && --y[r]==0) return -1;
else {
for(int i=0;i<2;i++) if(y[i]==1 && y[i]+(i==r)==1) return r=i;
}
}
if(y[0]+y[1]==1) {
d=true;
for(int i=0;i<2;i++) if(y[i]) {
if(i==r) return -1;
return r=i;
}
}
if(s.size()==4) {
int cnt=0;
d=true;
y[r]--;
for(int i=0;i<2;i++) if(y[i]) s.push_back('0'+i);
for(auto c: s) cnt+=c-'0';
s.push_back('0'+(cnt==2));
for(int i=0;i<6;i++) {
bool valid=true;
for(int j=0;j<4;j++) valid&=s[(i+j)%6]=='1'-j/2;
if(valid) for(int i=0;i<2;i++) if(y[i]) return r=i;
}
return -1;
}
if(r!=-1) y[r]--;
for(int i=0;i<2;i++) if(y[i]) {
if(r==-1) {
y[i]--;
for(int j=0;j<2;j++) if(y[j]) s.push_back('0'+j);
}
s.push_back('0'+i);
return r=i;
}
}
}
else {
for(int i=0;i<3;i++) if(y[i]==0 && y[(i+1)%3]==0) return r=(i+2)%3;
for(int i=0;i<3;i++) if(y[i]==0) return r=(i+1)%3;
}
}
Compilation message
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
77 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
15392 KB |
Output is correct |
2 |
Correct |
1 ms |
1128 KB |
Output is correct |
3 |
Correct |
36 ms |
14856 KB |
Output is correct |
4 |
Correct |
55 ms |
16436 KB |
Output is correct |
5 |
Correct |
59 ms |
16348 KB |
Output is correct |
6 |
Correct |
45 ms |
15144 KB |
Output is correct |
7 |
Correct |
45 ms |
15104 KB |
Output is correct |
8 |
Correct |
51 ms |
15828 KB |
Output is correct |
9 |
Correct |
49 ms |
15892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
15392 KB |
Output is correct |
2 |
Correct |
1 ms |
1128 KB |
Output is correct |
3 |
Correct |
36 ms |
14856 KB |
Output is correct |
4 |
Correct |
55 ms |
16436 KB |
Output is correct |
5 |
Correct |
59 ms |
16348 KB |
Output is correct |
6 |
Correct |
45 ms |
15144 KB |
Output is correct |
7 |
Correct |
45 ms |
15104 KB |
Output is correct |
8 |
Correct |
51 ms |
15828 KB |
Output is correct |
9 |
Correct |
49 ms |
15892 KB |
Output is correct |
10 |
Correct |
39 ms |
13388 KB |
Output is correct |
11 |
Correct |
40 ms |
13328 KB |
Output is correct |
12 |
Correct |
42 ms |
13204 KB |
Output is correct |
13 |
Correct |
38 ms |
13356 KB |
Output is correct |
14 |
Correct |
41 ms |
13620 KB |
Output is correct |
15 |
Correct |
46 ms |
13972 KB |
Output is correct |
16 |
Correct |
49 ms |
15940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
12980 KB |
Output is correct |
2 |
Correct |
2 ms |
1132 KB |
Output is correct |
3 |
Correct |
34 ms |
12676 KB |
Output is correct |
4 |
Correct |
56 ms |
14240 KB |
Output is correct |
5 |
Correct |
54 ms |
14156 KB |
Output is correct |
6 |
Correct |
41 ms |
12964 KB |
Output is correct |
7 |
Correct |
41 ms |
13068 KB |
Output is correct |
8 |
Correct |
48 ms |
13684 KB |
Output is correct |
9 |
Correct |
48 ms |
13568 KB |
Output is correct |
10 |
Correct |
47 ms |
13428 KB |
Output is correct |
11 |
Correct |
45 ms |
13368 KB |
Output is correct |
12 |
Correct |
44 ms |
13264 KB |
Output is correct |
13 |
Correct |
44 ms |
13364 KB |
Output is correct |
14 |
Correct |
49 ms |
13608 KB |
Output is correct |
15 |
Correct |
48 ms |
13588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
12980 KB |
Output is correct |
2 |
Correct |
2 ms |
1132 KB |
Output is correct |
3 |
Correct |
34 ms |
12676 KB |
Output is correct |
4 |
Correct |
56 ms |
14240 KB |
Output is correct |
5 |
Correct |
54 ms |
14156 KB |
Output is correct |
6 |
Correct |
41 ms |
12964 KB |
Output is correct |
7 |
Correct |
41 ms |
13068 KB |
Output is correct |
8 |
Correct |
48 ms |
13684 KB |
Output is correct |
9 |
Correct |
48 ms |
13568 KB |
Output is correct |
10 |
Correct |
47 ms |
13428 KB |
Output is correct |
11 |
Correct |
45 ms |
13368 KB |
Output is correct |
12 |
Correct |
44 ms |
13264 KB |
Output is correct |
13 |
Correct |
44 ms |
13364 KB |
Output is correct |
14 |
Correct |
49 ms |
13608 KB |
Output is correct |
15 |
Correct |
48 ms |
13588 KB |
Output is correct |
16 |
Correct |
36 ms |
11548 KB |
Output is correct |
17 |
Correct |
39 ms |
11508 KB |
Output is correct |
18 |
Correct |
37 ms |
11396 KB |
Output is correct |
19 |
Correct |
38 ms |
11532 KB |
Output is correct |
20 |
Correct |
44 ms |
12032 KB |
Output is correct |
21 |
Correct |
42 ms |
11776 KB |
Output is correct |
22 |
Correct |
48 ms |
13720 KB |
Output is correct |
23 |
Correct |
38 ms |
11488 KB |
Output is correct |
24 |
Correct |
39 ms |
11528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1388 KB |
Output is correct |
2 |
Correct |
1 ms |
1128 KB |
Output is correct |
3 |
Correct |
2 ms |
1388 KB |
Output is correct |
4 |
Correct |
2 ms |
1384 KB |
Output is correct |
5 |
Correct |
2 ms |
1388 KB |
Output is correct |
6 |
Correct |
2 ms |
1388 KB |
Output is correct |
7 |
Correct |
2 ms |
1388 KB |
Output is correct |
8 |
Correct |
2 ms |
1388 KB |
Output is correct |
9 |
Correct |
2 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
1400 KB |
Output is correct |
11 |
Correct |
2 ms |
1388 KB |
Output is correct |
12 |
Correct |
2 ms |
1388 KB |
Output is correct |
13 |
Correct |
2 ms |
1388 KB |
Output is correct |
14 |
Correct |
2 ms |
1388 KB |
Output is correct |
15 |
Correct |
2 ms |
1392 KB |
Output is correct |
16 |
Correct |
2 ms |
1396 KB |
Output is correct |
17 |
Correct |
2 ms |
1384 KB |
Output is correct |
18 |
Correct |
2 ms |
1396 KB |
Output is correct |
19 |
Correct |
2 ms |
1344 KB |
Output is correct |
20 |
Correct |
2 ms |
1388 KB |
Output is correct |
21 |
Correct |
2 ms |
1396 KB |
Output is correct |
22 |
Correct |
2 ms |
1388 KB |
Output is correct |
23 |
Correct |
2 ms |
1388 KB |
Output is correct |
24 |
Correct |
2 ms |
1396 KB |
Output is correct |
25 |
Correct |
2 ms |
1388 KB |
Output is correct |
26 |
Correct |
2 ms |
1388 KB |
Output is correct |
27 |
Correct |
2 ms |
1388 KB |
Output is correct |
28 |
Correct |
2 ms |
1388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
11124 KB |
Output is correct |
2 |
Correct |
42 ms |
11576 KB |
Output is correct |
3 |
Correct |
1 ms |
1128 KB |
Output is correct |
4 |
Correct |
33 ms |
11208 KB |
Output is correct |
5 |
Correct |
48 ms |
12200 KB |
Output is correct |
6 |
Correct |
49 ms |
12176 KB |
Output is correct |
7 |
Correct |
40 ms |
11444 KB |
Output is correct |
8 |
Correct |
40 ms |
11332 KB |
Output is correct |
9 |
Correct |
48 ms |
12176 KB |
Output is correct |
10 |
Correct |
50 ms |
12220 KB |
Output is correct |
11 |
Correct |
47 ms |
12332 KB |
Output is correct |
12 |
Correct |
47 ms |
12272 KB |
Output is correct |
13 |
Correct |
48 ms |
12236 KB |
Output is correct |
14 |
Correct |
47 ms |
12168 KB |
Output is correct |
15 |
Correct |
48 ms |
12184 KB |
Output is correct |
16 |
Correct |
49 ms |
12280 KB |
Output is correct |
17 |
Correct |
44 ms |
11952 KB |
Output is correct |
18 |
Correct |
45 ms |
11864 KB |
Output is correct |
19 |
Correct |
44 ms |
11940 KB |
Output is correct |
20 |
Correct |
44 ms |
11980 KB |
Output is correct |
21 |
Correct |
44 ms |
11928 KB |
Output is correct |
22 |
Correct |
44 ms |
11892 KB |
Output is correct |
23 |
Correct |
38 ms |
11180 KB |
Output is correct |
24 |
Correct |
41 ms |
11160 KB |
Output is correct |
25 |
Correct |
39 ms |
11208 KB |
Output is correct |
26 |
Correct |
40 ms |
11352 KB |
Output is correct |
27 |
Correct |
43 ms |
11740 KB |
Output is correct |
28 |
Correct |
43 ms |
11676 KB |
Output is correct |
29 |
Correct |
44 ms |
11692 KB |
Output is correct |
30 |
Correct |
43 ms |
11664 KB |
Output is correct |
31 |
Correct |
39 ms |
11216 KB |
Output is correct |
32 |
Correct |
39 ms |
11280 KB |
Output is correct |
33 |
Correct |
39 ms |
11148 KB |
Output is correct |
34 |
Correct |
39 ms |
11348 KB |
Output is correct |
35 |
Correct |
42 ms |
11688 KB |
Output is correct |
36 |
Correct |
44 ms |
11620 KB |
Output is correct |
37 |
Correct |
43 ms |
11596 KB |
Output is correct |
38 |
Correct |
43 ms |
11676 KB |
Output is correct |
39 |
Correct |
43 ms |
11652 KB |
Output is correct |
40 |
Correct |
44 ms |
11672 KB |
Output is correct |
41 |
Correct |
44 ms |
11904 KB |
Output is correct |
42 |
Correct |
45 ms |
11908 KB |
Output is correct |
43 |
Correct |
44 ms |
11848 KB |
Output is correct |
44 |
Correct |
44 ms |
11920 KB |
Output is correct |
45 |
Correct |
46 ms |
11936 KB |
Output is correct |
46 |
Correct |
45 ms |
11948 KB |
Output is correct |
47 |
Correct |
41 ms |
11568 KB |
Output is correct |
48 |
Correct |
42 ms |
11484 KB |
Output is correct |
49 |
Correct |
42 ms |
11464 KB |
Output is correct |
50 |
Correct |
42 ms |
11620 KB |
Output is correct |
51 |
Correct |
40 ms |
11408 KB |
Output is correct |
52 |
Correct |
41 ms |
11416 KB |
Output is correct |
53 |
Correct |
41 ms |
11584 KB |
Output is correct |
54 |
Correct |
39 ms |
11356 KB |
Output is correct |
55 |
Correct |
39 ms |
11276 KB |
Output is correct |
56 |
Correct |
40 ms |
11340 KB |
Output is correct |
57 |
Correct |
40 ms |
11140 KB |
Output is correct |
58 |
Correct |
39 ms |
11160 KB |
Output is correct |
59 |
Correct |
39 ms |
11224 KB |
Output is correct |
60 |
Correct |
40 ms |
11348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
11092 KB |
Output is correct |
2 |
Correct |
41 ms |
11464 KB |
Output is correct |
3 |
Correct |
1 ms |
1128 KB |
Output is correct |
4 |
Correct |
32 ms |
11156 KB |
Output is correct |
5 |
Correct |
49 ms |
12200 KB |
Output is correct |
6 |
Correct |
49 ms |
12164 KB |
Output is correct |
7 |
Correct |
44 ms |
11312 KB |
Output is correct |
8 |
Correct |
40 ms |
11312 KB |
Output is correct |
9 |
Correct |
49 ms |
12776 KB |
Output is correct |
10 |
Correct |
49 ms |
12648 KB |
Output is correct |
11 |
Correct |
47 ms |
12656 KB |
Output is correct |
12 |
Correct |
47 ms |
12744 KB |
Output is correct |
13 |
Correct |
49 ms |
12668 KB |
Output is correct |
14 |
Correct |
51 ms |
12612 KB |
Output is correct |
15 |
Correct |
47 ms |
12692 KB |
Output is correct |
16 |
Correct |
49 ms |
12684 KB |
Output is correct |
17 |
Correct |
48 ms |
12340 KB |
Output is correct |
18 |
Correct |
44 ms |
12400 KB |
Output is correct |
19 |
Correct |
45 ms |
12400 KB |
Output is correct |
20 |
Correct |
47 ms |
12372 KB |
Output is correct |
21 |
Correct |
45 ms |
12368 KB |
Output is correct |
22 |
Correct |
44 ms |
12380 KB |
Output is correct |
23 |
Correct |
38 ms |
11628 KB |
Output is correct |
24 |
Correct |
38 ms |
11684 KB |
Output is correct |
25 |
Correct |
39 ms |
11788 KB |
Output is correct |
26 |
Correct |
41 ms |
11704 KB |
Output is correct |
27 |
Correct |
46 ms |
12088 KB |
Output is correct |
28 |
Correct |
44 ms |
12228 KB |
Output is correct |
29 |
Correct |
45 ms |
12132 KB |
Output is correct |
30 |
Correct |
45 ms |
12128 KB |
Output is correct |
31 |
Correct |
38 ms |
11628 KB |
Output is correct |
32 |
Correct |
38 ms |
11632 KB |
Output is correct |
33 |
Correct |
49 ms |
11788 KB |
Output is correct |
34 |
Correct |
40 ms |
11812 KB |
Output is correct |
35 |
Correct |
43 ms |
12072 KB |
Output is correct |
36 |
Correct |
43 ms |
12152 KB |
Output is correct |
37 |
Correct |
43 ms |
12144 KB |
Output is correct |
38 |
Correct |
44 ms |
12140 KB |
Output is correct |
39 |
Correct |
42 ms |
12168 KB |
Output is correct |
40 |
Correct |
43 ms |
12140 KB |
Output is correct |
41 |
Correct |
45 ms |
12384 KB |
Output is correct |
42 |
Correct |
47 ms |
12276 KB |
Output is correct |
43 |
Correct |
45 ms |
12364 KB |
Output is correct |
44 |
Correct |
45 ms |
12264 KB |
Output is correct |
45 |
Correct |
45 ms |
12344 KB |
Output is correct |
46 |
Correct |
45 ms |
12344 KB |
Output is correct |
47 |
Correct |
43 ms |
12032 KB |
Output is correct |
48 |
Correct |
42 ms |
12052 KB |
Output is correct |
49 |
Correct |
41 ms |
11872 KB |
Output is correct |
50 |
Correct |
42 ms |
11956 KB |
Output is correct |
51 |
Correct |
40 ms |
11792 KB |
Output is correct |
52 |
Correct |
40 ms |
11816 KB |
Output is correct |
53 |
Correct |
39 ms |
11872 KB |
Output is correct |
54 |
Correct |
39 ms |
11784 KB |
Output is correct |
55 |
Correct |
39 ms |
11772 KB |
Output is correct |
56 |
Correct |
40 ms |
11768 KB |
Output is correct |
57 |
Correct |
39 ms |
11720 KB |
Output is correct |
58 |
Correct |
38 ms |
11664 KB |
Output is correct |
59 |
Correct |
39 ms |
11792 KB |
Output is correct |
60 |
Correct |
41 ms |
11872 KB |
Output is correct |