#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };
#include "Anthony.h"
Vi Mark(int N, int M, int A, int B, Vi U, Vi V){
vector<Vi> v(N);
fup(i,0,M-1,1){
v[U[i]].pb(V[i]);
v[V[i]].pb(U[i]);
}
Vi res(M),c(N);
Vi d(N,-1);
queue<int> q;
q.push(0);
d[0]=0;
while(!q.empty()){
int x=q.front();
q.pop();
for(int y:v[x]){
if(d[y]==-1){
d[y]=d[x]+1;
q.push(y);
if(A==2){
if(x==0)c[y]=0;
else if(v[x].size()>2)c[y]="010011"[c[x]]=='0'?1:0;
else c[y]=(c[x]+1)%6;
}
}
}
}
if(A==2){
fup(i,0,M-1,1){
int t=d[U[i]]>d[V[i]]?U[i]:V[i];
res[i]="010011"[c[t]]-'0';
}
}else{
fup(i,0,M-1,1){
int t=min(d[U[i]],d[V[i]]);
res[i]=t%3;
}
}
return res;
}
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define COMPRESS(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin())
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };
#include "Catherine.h"
int a,b;
int pr=-1;
bool ok;
string s;
void Init(int A,int B){
a=A,b=B;
}
int Move(Vi y){
if(a==2){
Vi yy=y;
if(pr!=-1)yy[pr]++;
int deg=yy[0]+yy[1];
if(deg!=2){
ok=1;
int r;
if(yy[0]==1)r=0;
else r=1;
if(r==pr)r=-1;
else pr=r;
return r;
}
if(ok){
if(y[0]==1)return pr=0;
return pr=1;
}
fup(i,0,1,1){
fup(k,0,y[i]-1,1)s+=(char)(i+'0');
}
if(s.length()==5){
ok=1;
fup(i,0,5,1){
if(s==string("010011010011").substr(i,5)){
return -1;
}
}
if(y[0]==1)return pr=0;
return pr=1;
}
int r=(int)(s.back()-'0');
pr=r;
return r;
}else{
if(y[0]==0 && y[1]==0)return 2;
if(y[0]==0 && y[2]==0)return 1;
if(y[1]==0 && y[2]==0)return 0;
fup(j,0,2,1)if(y[j]==0)return (j+1)%3;
return -1;
}
}
Compilation message
Anthony.cpp: In function 'Vi Mark(int, int, int, int, Vi, Vi)':
Anthony.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
Anthony.cpp:47:2: note: in expansion of macro 'fup'
47 | fup(i,0,M-1,1){
| ^~~
Anthony.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
Anthony.cpp:72:3: note: in expansion of macro 'fup'
72 | fup(i,0,M-1,1){
| ^~~
Anthony.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
Anthony.cpp:77:3: note: in expansion of macro 'fup'
77 | fup(i,0,M-1,1){
| ^~~
Catherine.cpp: In function 'int Move(Vi)':
Catherine.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
Catherine.cpp:71:3: note: in expansion of macro 'fup'
71 | fup(i,0,1,1){
| ^~~
Catherine.cpp:10:30: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
Catherine.cpp:72:4: note: in expansion of macro 'fup'
72 | fup(k,0,y[i]-1,1)s+=(char)(i+'0');
| ^~~
Catherine.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
Catherine.cpp:76:4: note: in expansion of macro 'fup'
76 | fup(i,0,5,1){
| ^~~
Catherine.cpp:10:30: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
| ^
Catherine.cpp:91:3: note: in expansion of macro 'fup'
91 | fup(j,0,2,1)if(y[j]==0)return (j+1)%3;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
14984 KB |
Output is correct |
2 |
Correct |
0 ms |
484 KB |
Output is correct |
3 |
Correct |
40 ms |
14424 KB |
Output is correct |
4 |
Correct |
56 ms |
16160 KB |
Output is correct |
5 |
Correct |
62 ms |
16192 KB |
Output is correct |
6 |
Correct |
44 ms |
14792 KB |
Output is correct |
7 |
Correct |
55 ms |
14764 KB |
Output is correct |
8 |
Correct |
57 ms |
15568 KB |
Output is correct |
9 |
Correct |
53 ms |
15644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
14984 KB |
Output is correct |
2 |
Correct |
0 ms |
484 KB |
Output is correct |
3 |
Correct |
40 ms |
14424 KB |
Output is correct |
4 |
Correct |
56 ms |
16160 KB |
Output is correct |
5 |
Correct |
62 ms |
16192 KB |
Output is correct |
6 |
Correct |
44 ms |
14792 KB |
Output is correct |
7 |
Correct |
55 ms |
14764 KB |
Output is correct |
8 |
Correct |
57 ms |
15568 KB |
Output is correct |
9 |
Correct |
53 ms |
15644 KB |
Output is correct |
10 |
Correct |
40 ms |
12796 KB |
Output is correct |
11 |
Correct |
44 ms |
12800 KB |
Output is correct |
12 |
Correct |
47 ms |
12808 KB |
Output is correct |
13 |
Correct |
39 ms |
12724 KB |
Output is correct |
14 |
Correct |
41 ms |
13112 KB |
Output is correct |
15 |
Correct |
49 ms |
13444 KB |
Output is correct |
16 |
Correct |
51 ms |
15708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
12560 KB |
Output is correct |
2 |
Correct |
0 ms |
484 KB |
Output is correct |
3 |
Correct |
34 ms |
12344 KB |
Output is correct |
4 |
Correct |
55 ms |
13928 KB |
Output is correct |
5 |
Correct |
54 ms |
13952 KB |
Output is correct |
6 |
Correct |
42 ms |
12560 KB |
Output is correct |
7 |
Correct |
49 ms |
12544 KB |
Output is correct |
8 |
Correct |
57 ms |
13232 KB |
Output is correct |
9 |
Correct |
49 ms |
13244 KB |
Output is correct |
10 |
Correct |
49 ms |
12952 KB |
Output is correct |
11 |
Correct |
46 ms |
13068 KB |
Output is correct |
12 |
Correct |
48 ms |
13036 KB |
Output is correct |
13 |
Correct |
47 ms |
12932 KB |
Output is correct |
14 |
Correct |
51 ms |
13392 KB |
Output is correct |
15 |
Correct |
49 ms |
13204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
12560 KB |
Output is correct |
2 |
Correct |
0 ms |
484 KB |
Output is correct |
3 |
Correct |
34 ms |
12344 KB |
Output is correct |
4 |
Correct |
55 ms |
13928 KB |
Output is correct |
5 |
Correct |
54 ms |
13952 KB |
Output is correct |
6 |
Correct |
42 ms |
12560 KB |
Output is correct |
7 |
Correct |
49 ms |
12544 KB |
Output is correct |
8 |
Correct |
57 ms |
13232 KB |
Output is correct |
9 |
Correct |
49 ms |
13244 KB |
Output is correct |
10 |
Correct |
49 ms |
12952 KB |
Output is correct |
11 |
Correct |
46 ms |
13068 KB |
Output is correct |
12 |
Correct |
48 ms |
13036 KB |
Output is correct |
13 |
Correct |
47 ms |
12932 KB |
Output is correct |
14 |
Correct |
51 ms |
13392 KB |
Output is correct |
15 |
Correct |
49 ms |
13204 KB |
Output is correct |
16 |
Correct |
36 ms |
11096 KB |
Output is correct |
17 |
Correct |
37 ms |
10856 KB |
Output is correct |
18 |
Correct |
40 ms |
10992 KB |
Output is correct |
19 |
Correct |
45 ms |
10908 KB |
Output is correct |
20 |
Correct |
44 ms |
11540 KB |
Output is correct |
21 |
Correct |
44 ms |
11244 KB |
Output is correct |
22 |
Correct |
48 ms |
13480 KB |
Output is correct |
23 |
Correct |
38 ms |
10928 KB |
Output is correct |
24 |
Correct |
38 ms |
11068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
880 KB |
Output is correct |
2 |
Correct |
0 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
876 KB |
Output is correct |
4 |
Correct |
3 ms |
872 KB |
Output is correct |
5 |
Correct |
2 ms |
872 KB |
Output is correct |
6 |
Correct |
2 ms |
872 KB |
Output is correct |
7 |
Correct |
2 ms |
872 KB |
Output is correct |
8 |
Correct |
2 ms |
872 KB |
Output is correct |
9 |
Correct |
2 ms |
872 KB |
Output is correct |
10 |
Correct |
2 ms |
872 KB |
Output is correct |
11 |
Correct |
2 ms |
872 KB |
Output is correct |
12 |
Correct |
2 ms |
872 KB |
Output is correct |
13 |
Correct |
2 ms |
836 KB |
Output is correct |
14 |
Correct |
2 ms |
876 KB |
Output is correct |
15 |
Correct |
2 ms |
876 KB |
Output is correct |
16 |
Correct |
2 ms |
876 KB |
Output is correct |
17 |
Correct |
2 ms |
884 KB |
Output is correct |
18 |
Correct |
2 ms |
884 KB |
Output is correct |
19 |
Correct |
2 ms |
884 KB |
Output is correct |
20 |
Correct |
2 ms |
872 KB |
Output is correct |
21 |
Correct |
2 ms |
876 KB |
Output is correct |
22 |
Correct |
2 ms |
876 KB |
Output is correct |
23 |
Correct |
2 ms |
876 KB |
Output is correct |
24 |
Correct |
2 ms |
884 KB |
Output is correct |
25 |
Correct |
2 ms |
876 KB |
Output is correct |
26 |
Correct |
2 ms |
840 KB |
Output is correct |
27 |
Correct |
2 ms |
876 KB |
Output is correct |
28 |
Correct |
2 ms |
876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
10836 KB |
Output is correct |
2 |
Correct |
44 ms |
11652 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
34 ms |
11080 KB |
Output is correct |
5 |
Correct |
49 ms |
12360 KB |
Output is correct |
6 |
Correct |
52 ms |
12384 KB |
Output is correct |
7 |
Correct |
41 ms |
11520 KB |
Output is correct |
8 |
Correct |
44 ms |
11488 KB |
Output is correct |
9 |
Correct |
54 ms |
12324 KB |
Output is correct |
10 |
Correct |
49 ms |
12376 KB |
Output is correct |
11 |
Correct |
49 ms |
12444 KB |
Output is correct |
12 |
Correct |
51 ms |
12324 KB |
Output is correct |
13 |
Correct |
49 ms |
12348 KB |
Output is correct |
14 |
Correct |
49 ms |
12388 KB |
Output is correct |
15 |
Correct |
51 ms |
12440 KB |
Output is correct |
16 |
Correct |
49 ms |
12376 KB |
Output is correct |
17 |
Correct |
46 ms |
12148 KB |
Output is correct |
18 |
Correct |
48 ms |
12276 KB |
Output is correct |
19 |
Correct |
46 ms |
12124 KB |
Output is correct |
20 |
Correct |
45 ms |
12184 KB |
Output is correct |
21 |
Correct |
46 ms |
12164 KB |
Output is correct |
22 |
Correct |
46 ms |
12132 KB |
Output is correct |
23 |
Correct |
39 ms |
11228 KB |
Output is correct |
24 |
Correct |
40 ms |
11308 KB |
Output is correct |
25 |
Correct |
40 ms |
11328 KB |
Output is correct |
26 |
Correct |
40 ms |
11408 KB |
Output is correct |
27 |
Correct |
46 ms |
11752 KB |
Output is correct |
28 |
Correct |
45 ms |
11744 KB |
Output is correct |
29 |
Correct |
45 ms |
11744 KB |
Output is correct |
30 |
Correct |
48 ms |
11864 KB |
Output is correct |
31 |
Correct |
39 ms |
11192 KB |
Output is correct |
32 |
Correct |
39 ms |
11228 KB |
Output is correct |
33 |
Correct |
42 ms |
11388 KB |
Output is correct |
34 |
Correct |
40 ms |
11260 KB |
Output is correct |
35 |
Correct |
48 ms |
11756 KB |
Output is correct |
36 |
Correct |
43 ms |
11804 KB |
Output is correct |
37 |
Correct |
46 ms |
11816 KB |
Output is correct |
38 |
Correct |
44 ms |
11776 KB |
Output is correct |
39 |
Correct |
45 ms |
11836 KB |
Output is correct |
40 |
Correct |
44 ms |
11752 KB |
Output is correct |
41 |
Correct |
45 ms |
12032 KB |
Output is correct |
42 |
Correct |
46 ms |
12024 KB |
Output is correct |
43 |
Correct |
45 ms |
12024 KB |
Output is correct |
44 |
Correct |
49 ms |
12024 KB |
Output is correct |
45 |
Correct |
46 ms |
12024 KB |
Output is correct |
46 |
Correct |
46 ms |
11980 KB |
Output is correct |
47 |
Correct |
43 ms |
11572 KB |
Output is correct |
48 |
Correct |
44 ms |
11684 KB |
Output is correct |
49 |
Correct |
41 ms |
11528 KB |
Output is correct |
50 |
Correct |
43 ms |
11648 KB |
Output is correct |
51 |
Correct |
39 ms |
11412 KB |
Output is correct |
52 |
Correct |
39 ms |
11540 KB |
Output is correct |
53 |
Correct |
39 ms |
11484 KB |
Output is correct |
54 |
Correct |
39 ms |
11552 KB |
Output is correct |
55 |
Correct |
39 ms |
11516 KB |
Output is correct |
56 |
Correct |
39 ms |
11520 KB |
Output is correct |
57 |
Correct |
41 ms |
11356 KB |
Output is correct |
58 |
Correct |
39 ms |
11408 KB |
Output is correct |
59 |
Correct |
40 ms |
11456 KB |
Output is correct |
60 |
Correct |
40 ms |
11476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
10748 KB |
Output is correct |
2 |
Correct |
41 ms |
11032 KB |
Output is correct |
3 |
Correct |
1 ms |
488 KB |
Output is correct |
4 |
Correct |
34 ms |
11112 KB |
Output is correct |
5 |
Correct |
51 ms |
12444 KB |
Output is correct |
6 |
Correct |
49 ms |
12392 KB |
Output is correct |
7 |
Correct |
41 ms |
11504 KB |
Output is correct |
8 |
Correct |
40 ms |
11552 KB |
Output is correct |
9 |
Correct |
51 ms |
12476 KB |
Output is correct |
10 |
Correct |
53 ms |
12412 KB |
Output is correct |
11 |
Correct |
49 ms |
12420 KB |
Output is correct |
12 |
Correct |
56 ms |
12372 KB |
Output is correct |
13 |
Correct |
51 ms |
12400 KB |
Output is correct |
14 |
Correct |
49 ms |
12396 KB |
Output is correct |
15 |
Correct |
48 ms |
12392 KB |
Output is correct |
16 |
Correct |
50 ms |
12384 KB |
Output is correct |
17 |
Correct |
45 ms |
12144 KB |
Output is correct |
18 |
Correct |
48 ms |
12120 KB |
Output is correct |
19 |
Correct |
48 ms |
12052 KB |
Output is correct |
20 |
Correct |
46 ms |
12152 KB |
Output is correct |
21 |
Correct |
46 ms |
12136 KB |
Output is correct |
22 |
Correct |
49 ms |
12088 KB |
Output is correct |
23 |
Correct |
39 ms |
11156 KB |
Output is correct |
24 |
Correct |
38 ms |
11244 KB |
Output is correct |
25 |
Correct |
41 ms |
11372 KB |
Output is correct |
26 |
Correct |
40 ms |
11432 KB |
Output is correct |
27 |
Correct |
45 ms |
11832 KB |
Output is correct |
28 |
Correct |
45 ms |
11772 KB |
Output is correct |
29 |
Correct |
48 ms |
11856 KB |
Output is correct |
30 |
Correct |
46 ms |
11804 KB |
Output is correct |
31 |
Correct |
38 ms |
11312 KB |
Output is correct |
32 |
Correct |
38 ms |
11256 KB |
Output is correct |
33 |
Correct |
39 ms |
11424 KB |
Output is correct |
34 |
Correct |
40 ms |
11428 KB |
Output is correct |
35 |
Correct |
45 ms |
11800 KB |
Output is correct |
36 |
Correct |
45 ms |
11684 KB |
Output is correct |
37 |
Correct |
45 ms |
11800 KB |
Output is correct |
38 |
Correct |
43 ms |
11792 KB |
Output is correct |
39 |
Correct |
44 ms |
11628 KB |
Output is correct |
40 |
Correct |
44 ms |
11724 KB |
Output is correct |
41 |
Correct |
46 ms |
11948 KB |
Output is correct |
42 |
Correct |
47 ms |
11992 KB |
Output is correct |
43 |
Correct |
47 ms |
11992 KB |
Output is correct |
44 |
Correct |
48 ms |
12056 KB |
Output is correct |
45 |
Correct |
47 ms |
12084 KB |
Output is correct |
46 |
Correct |
49 ms |
12044 KB |
Output is correct |
47 |
Correct |
43 ms |
11608 KB |
Output is correct |
48 |
Correct |
44 ms |
11616 KB |
Output is correct |
49 |
Correct |
44 ms |
11488 KB |
Output is correct |
50 |
Correct |
44 ms |
11636 KB |
Output is correct |
51 |
Correct |
41 ms |
11460 KB |
Output is correct |
52 |
Correct |
40 ms |
11544 KB |
Output is correct |
53 |
Correct |
39 ms |
11464 KB |
Output is correct |
54 |
Correct |
40 ms |
11368 KB |
Output is correct |
55 |
Correct |
40 ms |
11564 KB |
Output is correct |
56 |
Correct |
39 ms |
11556 KB |
Output is correct |
57 |
Correct |
40 ms |
11376 KB |
Output is correct |
58 |
Correct |
41 ms |
11452 KB |
Output is correct |
59 |
Correct |
39 ms |
11444 KB |
Output is correct |
60 |
Correct |
39 ms |
11484 KB |
Output is correct |