#include "Anthony.h"
#include <vector>
#include<bits/stdc++.h>
namespace {
using namespace std;
#define f first
#define s second
int A,B;
const int mxn=2e4+5;
vector<pair<int,int>> adj[mxn];
vector<int> ans;
vector<int> ch={0,0,1,0,1,1};
bool visited[mxn];
int depth[mxn];
int par[mxn];
void dfs(int v,int p=-1,int c=0,int cur=-1){
for(auto u:adj[v]){
if(u.f==p) continue;
if(v!=0 and (int)adj[v].size()==2){
if(cur==-1){
if(c==0) cur=2;
else cur=0;
}
ans[u.s]=ch[cur];
dfs(u.f,v,ans[u.s],(cur+1)%6);
}
else{
ans[u.s]=(c+1)%2;
dfs(u.f,v,ans[u.s],-1);
}
}
}
void bfs(){
queue<pair<int,int>> q;
q.push({0,0});
visited[0]=true;
while(!q.empty()){
int v=q.front().f;
int c=q.front().s;
q.pop();
for(auto u:adj[v]){
if(visited[u.f]){
if(u.f!=par[v]){
if(depth[v]==depth[u.f]){
ans[u.s]=(c+1)%3;
}
else if(depth[v]<depth[u.f]){
ans[u.s]=(c+1)%3;
}
}
continue;
}
visited[u.f]=true;
ans[u.s]=(c+1)%3;
depth[u.f]=depth[v]+1;
q.push({u.f,ans[u.s]});
}
}
}
} // namespace
std::vector<int> Mark(int N, int M, int A, int B,std::vector<int> U, std::vector<int> V) {
::A = A;
::B = B;
ans.resize(M);
for(int i=0;i<M;i++){
adj[U[i]].push_back({V[i],i});
adj[V[i]].push_back({U[i],i});
}
if(A==2) dfs(0);
else bfs();
//ans=vector<int>(M,0);
return ans;
}
#include "Catherine.h"
#include <vector>
#include<bits/stdc++.h>
namespace {
using namespace std;
#define all(x) x.begin(),x.end()
int A, B;
int variable_example = 0;
int prv=-1;
map<vector<int>,int> down,up;
vector<int> ch={0,0,1,0,1,1};
bool on=false;
bool dir=false;
vector<int> cur;
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
for(int i=0;i<6;i++){
vector<int> tmp;
for(int j=0;j<5;j++){
tmp.push_back(ch[(i+j)%6]);
}
down[tmp]++;
}
reverse(all(ch));
for(int i=0;i<6;i++){
vector<int> tmp;
for(int j=0;j<5;j++){
tmp.push_back(ch[(i+j)%6]);
}
up[tmp]++;
}
}
int Move(std::vector<int> y) {
if(A==2){
if(prv!=-1) y[prv]++;
if((y[0]>1 and y[1]==1) or (y[1]>1 and y[0]==1)){
dir=true;
if(y[0]>1){
if(prv==1){
prv=1;
return -1;
}
else{
prv=1;
return 1;
}
}
else{
if(prv==0){
prv=0;
return -1;
}
else{
prv=0;
return 0;
}
}
}
if(y[0]+y[1]==1){
dir=true;
if(y[0]==1){
if(prv==-1){
prv=0;
return 0;
}
else{
prv=0;
return -1;
}
}
else{
if(prv==-1){
prv=1;
return 1;
}
else{
prv=1;
return -1;
}
}
}
if(dir==true){
y[prv]--;
if(y[0]>0){
prv=0;
}
else{
prv=1;
}
return prv;
}
if(on==true){
cur.push_back(prv);
if((int)cur.size()==4){
y[prv]--;
if(y[0]>0) cur.push_back(0);
else cur.push_back(1);
y[prv]++;
if(up.find(cur)!=up.end()){
dir=true;
prv=cur.back();
return prv;
}
else{
dir=true;
return -1;
}
}
else{
y[prv]--;
if(y[0]>0){
prv=0;
return prv;
}
else{
prv=1;
return prv;
}
}
}
else{
on=true;
vector<int> edge;
for(int i=0;i<2;i++){
for(int j=0;j<y[i];j++) edge.push_back(i);
}
cur.push_back(edge[0]);
prv=edge[1];
return prv;
}
}
else{
vector<int> pos;
for(int i=0;i<(int)y.size();i++){
if(y[i]>0) pos.push_back(i);
}
if((int)pos.size()==1) return pos[0];
else{
if((pos[0]+1)%3==pos[1]) return pos[0];
else return pos[1];
}
}
}
Compilation message
Catherine.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
8 | int variable_example = 0;
| ^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
15500 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
26 ms |
15648 KB |
Output is correct |
4 |
Correct |
39 ms |
17380 KB |
Output is correct |
5 |
Correct |
34 ms |
17220 KB |
Output is correct |
6 |
Correct |
30 ms |
15940 KB |
Output is correct |
7 |
Correct |
32 ms |
15788 KB |
Output is correct |
8 |
Correct |
36 ms |
16728 KB |
Output is correct |
9 |
Correct |
33 ms |
16704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
15500 KB |
Output is correct |
2 |
Correct |
1 ms |
1300 KB |
Output is correct |
3 |
Correct |
26 ms |
15648 KB |
Output is correct |
4 |
Correct |
39 ms |
17380 KB |
Output is correct |
5 |
Correct |
34 ms |
17220 KB |
Output is correct |
6 |
Correct |
30 ms |
15940 KB |
Output is correct |
7 |
Correct |
32 ms |
15788 KB |
Output is correct |
8 |
Correct |
36 ms |
16728 KB |
Output is correct |
9 |
Correct |
33 ms |
16704 KB |
Output is correct |
10 |
Correct |
28 ms |
13980 KB |
Output is correct |
11 |
Correct |
27 ms |
13924 KB |
Output is correct |
12 |
Correct |
30 ms |
13948 KB |
Output is correct |
13 |
Correct |
26 ms |
14132 KB |
Output is correct |
14 |
Correct |
34 ms |
14320 KB |
Output is correct |
15 |
Correct |
31 ms |
14656 KB |
Output is correct |
16 |
Correct |
34 ms |
16604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
13172 KB |
Output is correct |
2 |
Correct |
1 ms |
1296 KB |
Output is correct |
3 |
Correct |
30 ms |
13420 KB |
Output is correct |
4 |
Correct |
48 ms |
15092 KB |
Output is correct |
5 |
Correct |
46 ms |
15092 KB |
Output is correct |
6 |
Correct |
27 ms |
13640 KB |
Output is correct |
7 |
Correct |
26 ms |
13772 KB |
Output is correct |
8 |
Correct |
31 ms |
14416 KB |
Output is correct |
9 |
Correct |
32 ms |
14332 KB |
Output is correct |
10 |
Correct |
31 ms |
14072 KB |
Output is correct |
11 |
Correct |
31 ms |
14216 KB |
Output is correct |
12 |
Correct |
38 ms |
14148 KB |
Output is correct |
13 |
Correct |
41 ms |
14000 KB |
Output is correct |
14 |
Correct |
36 ms |
14400 KB |
Output is correct |
15 |
Correct |
32 ms |
14324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
13172 KB |
Output is correct |
2 |
Correct |
1 ms |
1296 KB |
Output is correct |
3 |
Correct |
30 ms |
13420 KB |
Output is correct |
4 |
Correct |
48 ms |
15092 KB |
Output is correct |
5 |
Correct |
46 ms |
15092 KB |
Output is correct |
6 |
Correct |
27 ms |
13640 KB |
Output is correct |
7 |
Correct |
26 ms |
13772 KB |
Output is correct |
8 |
Correct |
31 ms |
14416 KB |
Output is correct |
9 |
Correct |
32 ms |
14332 KB |
Output is correct |
10 |
Correct |
31 ms |
14072 KB |
Output is correct |
11 |
Correct |
31 ms |
14216 KB |
Output is correct |
12 |
Correct |
38 ms |
14148 KB |
Output is correct |
13 |
Correct |
41 ms |
14000 KB |
Output is correct |
14 |
Correct |
36 ms |
14400 KB |
Output is correct |
15 |
Correct |
32 ms |
14324 KB |
Output is correct |
16 |
Correct |
24 ms |
12076 KB |
Output is correct |
17 |
Correct |
24 ms |
12056 KB |
Output is correct |
18 |
Correct |
27 ms |
12140 KB |
Output is correct |
19 |
Correct |
27 ms |
12268 KB |
Output is correct |
20 |
Correct |
37 ms |
12880 KB |
Output is correct |
21 |
Correct |
31 ms |
12824 KB |
Output is correct |
22 |
Correct |
33 ms |
14680 KB |
Output is correct |
23 |
Correct |
25 ms |
12212 KB |
Output is correct |
24 |
Correct |
32 ms |
12264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1552 KB |
Output is correct |
2 |
Correct |
0 ms |
1804 KB |
Output is correct |
3 |
Correct |
2 ms |
1568 KB |
Output is correct |
4 |
Correct |
2 ms |
1564 KB |
Output is correct |
5 |
Correct |
2 ms |
1560 KB |
Output is correct |
6 |
Correct |
2 ms |
1568 KB |
Output is correct |
7 |
Correct |
2 ms |
1568 KB |
Output is correct |
8 |
Correct |
2 ms |
1568 KB |
Output is correct |
9 |
Correct |
2 ms |
1564 KB |
Output is correct |
10 |
Correct |
2 ms |
1556 KB |
Output is correct |
11 |
Correct |
2 ms |
1560 KB |
Output is correct |
12 |
Correct |
2 ms |
1552 KB |
Output is correct |
13 |
Correct |
2 ms |
1568 KB |
Output is correct |
14 |
Correct |
2 ms |
1552 KB |
Output is correct |
15 |
Correct |
2 ms |
1560 KB |
Output is correct |
16 |
Correct |
2 ms |
1560 KB |
Output is correct |
17 |
Correct |
2 ms |
1560 KB |
Output is correct |
18 |
Correct |
2 ms |
1564 KB |
Output is correct |
19 |
Correct |
2 ms |
1560 KB |
Output is correct |
20 |
Correct |
2 ms |
1568 KB |
Output is correct |
21 |
Correct |
2 ms |
1568 KB |
Output is correct |
22 |
Correct |
2 ms |
1568 KB |
Output is correct |
23 |
Correct |
2 ms |
1560 KB |
Output is correct |
24 |
Correct |
2 ms |
1568 KB |
Output is correct |
25 |
Correct |
2 ms |
1560 KB |
Output is correct |
26 |
Correct |
2 ms |
1552 KB |
Output is correct |
27 |
Correct |
2 ms |
1568 KB |
Output is correct |
28 |
Correct |
2 ms |
1564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
11384 KB |
Output is correct |
2 |
Correct |
28 ms |
12660 KB |
Output is correct |
3 |
Correct |
0 ms |
1296 KB |
Output is correct |
4 |
Correct |
20 ms |
11136 KB |
Output is correct |
5 |
Correct |
30 ms |
13900 KB |
Output is correct |
6 |
Correct |
31 ms |
13928 KB |
Output is correct |
7 |
Correct |
27 ms |
13080 KB |
Output is correct |
8 |
Correct |
26 ms |
12924 KB |
Output is correct |
9 |
Correct |
34 ms |
13864 KB |
Output is correct |
10 |
Correct |
31 ms |
14172 KB |
Output is correct |
11 |
Correct |
31 ms |
13876 KB |
Output is correct |
12 |
Correct |
32 ms |
13948 KB |
Output is correct |
13 |
Correct |
38 ms |
13928 KB |
Output is correct |
14 |
Correct |
31 ms |
13940 KB |
Output is correct |
15 |
Correct |
31 ms |
13952 KB |
Output is correct |
16 |
Correct |
32 ms |
13956 KB |
Output is correct |
17 |
Correct |
30 ms |
13652 KB |
Output is correct |
18 |
Correct |
28 ms |
13688 KB |
Output is correct |
19 |
Correct |
30 ms |
13656 KB |
Output is correct |
20 |
Correct |
35 ms |
13692 KB |
Output is correct |
21 |
Correct |
28 ms |
13680 KB |
Output is correct |
22 |
Correct |
30 ms |
13672 KB |
Output is correct |
23 |
Correct |
27 ms |
11336 KB |
Output is correct |
24 |
Correct |
25 ms |
11424 KB |
Output is correct |
25 |
Correct |
25 ms |
11896 KB |
Output is correct |
26 |
Correct |
26 ms |
11896 KB |
Output is correct |
27 |
Correct |
26 ms |
12924 KB |
Output is correct |
28 |
Correct |
28 ms |
12664 KB |
Output is correct |
29 |
Correct |
27 ms |
12924 KB |
Output is correct |
30 |
Correct |
27 ms |
12928 KB |
Output is correct |
31 |
Correct |
25 ms |
11332 KB |
Output is correct |
32 |
Correct |
26 ms |
11372 KB |
Output is correct |
33 |
Correct |
27 ms |
11960 KB |
Output is correct |
34 |
Correct |
25 ms |
11892 KB |
Output is correct |
35 |
Correct |
28 ms |
12596 KB |
Output is correct |
36 |
Correct |
27 ms |
12668 KB |
Output is correct |
37 |
Correct |
27 ms |
12668 KB |
Output is correct |
38 |
Correct |
26 ms |
12656 KB |
Output is correct |
39 |
Correct |
26 ms |
13084 KB |
Output is correct |
40 |
Correct |
26 ms |
12652 KB |
Output is correct |
41 |
Correct |
27 ms |
13184 KB |
Output is correct |
42 |
Correct |
30 ms |
13176 KB |
Output is correct |
43 |
Correct |
28 ms |
13260 KB |
Output is correct |
44 |
Correct |
31 ms |
13192 KB |
Output is correct |
45 |
Correct |
30 ms |
13176 KB |
Output is correct |
46 |
Correct |
32 ms |
13180 KB |
Output is correct |
47 |
Correct |
26 ms |
12352 KB |
Output is correct |
48 |
Correct |
27 ms |
12424 KB |
Output is correct |
49 |
Correct |
27 ms |
12232 KB |
Output is correct |
50 |
Correct |
27 ms |
12412 KB |
Output is correct |
51 |
Correct |
25 ms |
11640 KB |
Output is correct |
52 |
Correct |
26 ms |
11628 KB |
Output is correct |
53 |
Correct |
25 ms |
11644 KB |
Output is correct |
54 |
Correct |
25 ms |
11636 KB |
Output is correct |
55 |
Correct |
25 ms |
11688 KB |
Output is correct |
56 |
Correct |
25 ms |
11632 KB |
Output is correct |
57 |
Correct |
25 ms |
11892 KB |
Output is correct |
58 |
Correct |
26 ms |
11892 KB |
Output is correct |
59 |
Correct |
25 ms |
11440 KB |
Output is correct |
60 |
Correct |
30 ms |
11328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
11384 KB |
Output is correct |
2 |
Correct |
26 ms |
12376 KB |
Output is correct |
3 |
Correct |
1 ms |
1308 KB |
Output is correct |
4 |
Correct |
22 ms |
11104 KB |
Output is correct |
5 |
Correct |
32 ms |
13952 KB |
Output is correct |
6 |
Correct |
31 ms |
13948 KB |
Output is correct |
7 |
Correct |
26 ms |
13172 KB |
Output is correct |
8 |
Correct |
28 ms |
12920 KB |
Output is correct |
9 |
Correct |
31 ms |
13936 KB |
Output is correct |
10 |
Correct |
30 ms |
13948 KB |
Output is correct |
11 |
Correct |
31 ms |
13956 KB |
Output is correct |
12 |
Correct |
31 ms |
13956 KB |
Output is correct |
13 |
Correct |
31 ms |
13912 KB |
Output is correct |
14 |
Correct |
34 ms |
13876 KB |
Output is correct |
15 |
Correct |
31 ms |
13912 KB |
Output is correct |
16 |
Correct |
31 ms |
13964 KB |
Output is correct |
17 |
Correct |
30 ms |
13668 KB |
Output is correct |
18 |
Correct |
28 ms |
13696 KB |
Output is correct |
19 |
Correct |
31 ms |
13504 KB |
Output is correct |
20 |
Correct |
34 ms |
14112 KB |
Output is correct |
21 |
Correct |
30 ms |
13568 KB |
Output is correct |
22 |
Correct |
28 ms |
13684 KB |
Output is correct |
23 |
Correct |
27 ms |
11384 KB |
Output is correct |
24 |
Correct |
25 ms |
11380 KB |
Output is correct |
25 |
Correct |
25 ms |
12064 KB |
Output is correct |
26 |
Correct |
25 ms |
12140 KB |
Output is correct |
27 |
Correct |
27 ms |
12868 KB |
Output is correct |
28 |
Correct |
27 ms |
12700 KB |
Output is correct |
29 |
Correct |
28 ms |
13176 KB |
Output is correct |
30 |
Correct |
28 ms |
12756 KB |
Output is correct |
31 |
Correct |
25 ms |
11352 KB |
Output is correct |
32 |
Correct |
25 ms |
11384 KB |
Output is correct |
33 |
Correct |
26 ms |
11904 KB |
Output is correct |
34 |
Correct |
29 ms |
11972 KB |
Output is correct |
35 |
Correct |
32 ms |
12816 KB |
Output is correct |
36 |
Correct |
32 ms |
12740 KB |
Output is correct |
37 |
Correct |
28 ms |
12596 KB |
Output is correct |
38 |
Correct |
26 ms |
12668 KB |
Output is correct |
39 |
Correct |
27 ms |
12652 KB |
Output is correct |
40 |
Correct |
26 ms |
12720 KB |
Output is correct |
41 |
Correct |
33 ms |
13292 KB |
Output is correct |
42 |
Correct |
28 ms |
13180 KB |
Output is correct |
43 |
Correct |
28 ms |
13216 KB |
Output is correct |
44 |
Correct |
28 ms |
13184 KB |
Output is correct |
45 |
Correct |
28 ms |
13292 KB |
Output is correct |
46 |
Correct |
28 ms |
13260 KB |
Output is correct |
47 |
Correct |
27 ms |
12416 KB |
Output is correct |
48 |
Correct |
30 ms |
12408 KB |
Output is correct |
49 |
Correct |
26 ms |
12104 KB |
Output is correct |
50 |
Correct |
26 ms |
12436 KB |
Output is correct |
51 |
Correct |
25 ms |
11640 KB |
Output is correct |
52 |
Correct |
26 ms |
11636 KB |
Output is correct |
53 |
Correct |
25 ms |
11640 KB |
Output is correct |
54 |
Correct |
31 ms |
11644 KB |
Output is correct |
55 |
Correct |
25 ms |
11644 KB |
Output is correct |
56 |
Correct |
25 ms |
11604 KB |
Output is correct |
57 |
Correct |
25 ms |
12156 KB |
Output is correct |
58 |
Correct |
27 ms |
11908 KB |
Output is correct |
59 |
Correct |
25 ms |
11376 KB |
Output is correct |
60 |
Correct |
26 ms |
11380 KB |
Output is correct |