#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
namespace
{
int seq[]={1,0,1,1,0,0},dist[20005];
vector<pair<int,int> > v[20005];
vector<int> ans;
}
void dfs(int node,int p,int idx,int gp)
{
int c=(int)v[node].size()-(p!=-1);
for (auto u:v[node])
{
if (u.first!=p)
{
if (c==1)
{
ans[u.second]=seq[idx];
dfs(u.first,node,(idx+1)%6,seq[idx]);
}
else
{
ans[u.second]=!gp;
dfs(u.first,node,0,!gp);
}
}
}
}
vector<int> Mark(int n,int m,int A,int B,vector<int> a,vector<int> b)
{
for (int i=0;i<m;i++)
{
v[a[i]].push_back({b[i],i});
v[b[i]].push_back({a[i],i});
}
ans=vector<int>(m,-1);
if (A==2)
dfs(0,-1,0,0);
else
{
memset(dist,-1,sizeof(dist));
queue<int> q;
q.push(0);
dist[0]=0;
while (!q.empty())
{
int node=q.front();
q.pop();
for (auto u:v[node])
{
if (dist[u.first]==-1)
{
dist[u.first]=dist[node]+1;
q.push(u.first);
}
if (ans[u.second]==-1)
ans[u.second]=dist[node]%3;
}
}
}
return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace
{
bool f;
int l,seq[]={1,0,1,1,0,0};
vector<int> p;
}
void Init(int A, int B){}
int Move(vector<int> y)
{
if (y.size()>2)
{
if ((bool)y[0]+(bool)y[1]+(bool)y[2]==1)
{
for (int i=0;i<3;i++)
{
if (y[i])
return i;
}
}
for (int i=0;i<3;i++)
{
if (!y[i])
return (i+1)%3;
}
}
if (!f)
{
f=1;
bool b=(y[0]>y[1]);
if (!y[b])
b^=1;
if (y[0]+y[1]==2)
{
if (y[b]==2)
p.push_back(b);
else
p.push_back(!b);
p.push_back(b);
}
return l=b;
}
if (!y[0] && !y[1])
{
p.clear();
return -1;
}
if (y[0]+y[1]==1)
{
p.push_back(y[1]);
if (p.size()==6)
{
for (int i=0;i<6;i++)
{
bool eq=1;
for (int j=0;j<6;j++)
eq&=(p[j]==seq[(i+j)%6]);
if (eq)
{
p.clear();
return -1;
}
}
}
return l=y[1];
}
p.clear();
if (!y[l])
return -1;
l^=1;
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
15612 KB |
Output is correct |
2 |
Correct |
1 ms |
1792 KB |
Output is correct |
3 |
Correct |
41 ms |
14968 KB |
Output is correct |
4 |
Correct |
65 ms |
16920 KB |
Output is correct |
5 |
Correct |
68 ms |
16932 KB |
Output is correct |
6 |
Correct |
51 ms |
15612 KB |
Output is correct |
7 |
Correct |
50 ms |
15612 KB |
Output is correct |
8 |
Correct |
63 ms |
16360 KB |
Output is correct |
9 |
Correct |
66 ms |
16244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
15612 KB |
Output is correct |
2 |
Correct |
1 ms |
1792 KB |
Output is correct |
3 |
Correct |
41 ms |
14968 KB |
Output is correct |
4 |
Correct |
65 ms |
16920 KB |
Output is correct |
5 |
Correct |
68 ms |
16932 KB |
Output is correct |
6 |
Correct |
51 ms |
15612 KB |
Output is correct |
7 |
Correct |
50 ms |
15612 KB |
Output is correct |
8 |
Correct |
63 ms |
16360 KB |
Output is correct |
9 |
Correct |
66 ms |
16244 KB |
Output is correct |
10 |
Correct |
51 ms |
13688 KB |
Output is correct |
11 |
Correct |
50 ms |
13800 KB |
Output is correct |
12 |
Correct |
46 ms |
13688 KB |
Output is correct |
13 |
Correct |
46 ms |
13560 KB |
Output is correct |
14 |
Correct |
46 ms |
14048 KB |
Output is correct |
15 |
Correct |
55 ms |
14200 KB |
Output is correct |
16 |
Correct |
63 ms |
16244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
13308 KB |
Output is correct |
2 |
Correct |
1 ms |
1792 KB |
Output is correct |
3 |
Correct |
41 ms |
13044 KB |
Output is correct |
4 |
Correct |
73 ms |
14632 KB |
Output is correct |
5 |
Correct |
61 ms |
14588 KB |
Output is correct |
6 |
Correct |
47 ms |
13372 KB |
Output is correct |
7 |
Correct |
47 ms |
13368 KB |
Output is correct |
8 |
Correct |
56 ms |
14060 KB |
Output is correct |
9 |
Correct |
57 ms |
14300 KB |
Output is correct |
10 |
Correct |
52 ms |
13820 KB |
Output is correct |
11 |
Correct |
52 ms |
13920 KB |
Output is correct |
12 |
Correct |
51 ms |
14076 KB |
Output is correct |
13 |
Correct |
53 ms |
14168 KB |
Output is correct |
14 |
Correct |
59 ms |
14336 KB |
Output is correct |
15 |
Correct |
58 ms |
14068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
13308 KB |
Output is correct |
2 |
Correct |
1 ms |
1792 KB |
Output is correct |
3 |
Correct |
41 ms |
13044 KB |
Output is correct |
4 |
Correct |
73 ms |
14632 KB |
Output is correct |
5 |
Correct |
61 ms |
14588 KB |
Output is correct |
6 |
Correct |
47 ms |
13372 KB |
Output is correct |
7 |
Correct |
47 ms |
13368 KB |
Output is correct |
8 |
Correct |
56 ms |
14060 KB |
Output is correct |
9 |
Correct |
57 ms |
14300 KB |
Output is correct |
10 |
Correct |
52 ms |
13820 KB |
Output is correct |
11 |
Correct |
52 ms |
13920 KB |
Output is correct |
12 |
Correct |
51 ms |
14076 KB |
Output is correct |
13 |
Correct |
53 ms |
14168 KB |
Output is correct |
14 |
Correct |
59 ms |
14336 KB |
Output is correct |
15 |
Correct |
58 ms |
14068 KB |
Output is correct |
16 |
Correct |
41 ms |
11768 KB |
Output is correct |
17 |
Correct |
46 ms |
11964 KB |
Output is correct |
18 |
Correct |
43 ms |
11888 KB |
Output is correct |
19 |
Correct |
43 ms |
11996 KB |
Output is correct |
20 |
Correct |
52 ms |
12408 KB |
Output is correct |
21 |
Correct |
46 ms |
12152 KB |
Output is correct |
22 |
Correct |
58 ms |
14112 KB |
Output is correct |
23 |
Correct |
47 ms |
11896 KB |
Output is correct |
24 |
Correct |
47 ms |
12008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1536 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
2 ms |
1536 KB |
Output is correct |
4 |
Correct |
3 ms |
1792 KB |
Output is correct |
5 |
Correct |
2 ms |
1792 KB |
Output is correct |
6 |
Correct |
2 ms |
1792 KB |
Output is correct |
7 |
Correct |
2 ms |
1792 KB |
Output is correct |
8 |
Correct |
2 ms |
1792 KB |
Output is correct |
9 |
Correct |
2 ms |
1792 KB |
Output is correct |
10 |
Correct |
2 ms |
1792 KB |
Output is correct |
11 |
Correct |
2 ms |
1792 KB |
Output is correct |
12 |
Correct |
2 ms |
1792 KB |
Output is correct |
13 |
Correct |
2 ms |
1792 KB |
Output is correct |
14 |
Correct |
2 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
1792 KB |
Output is correct |
16 |
Correct |
2 ms |
1560 KB |
Output is correct |
17 |
Correct |
2 ms |
1536 KB |
Output is correct |
18 |
Correct |
2 ms |
1536 KB |
Output is correct |
19 |
Correct |
2 ms |
1792 KB |
Output is correct |
20 |
Correct |
2 ms |
1536 KB |
Output is correct |
21 |
Correct |
2 ms |
1536 KB |
Output is correct |
22 |
Correct |
2 ms |
1792 KB |
Output is correct |
23 |
Correct |
3 ms |
1792 KB |
Output is correct |
24 |
Correct |
2 ms |
1600 KB |
Output is correct |
25 |
Correct |
2 ms |
1536 KB |
Output is correct |
26 |
Correct |
2 ms |
1536 KB |
Output is correct |
27 |
Correct |
2 ms |
1792 KB |
Output is correct |
28 |
Correct |
3 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
11468 KB |
Output is correct |
2 |
Correct |
51 ms |
12660 KB |
Output is correct |
3 |
Correct |
1 ms |
1536 KB |
Output is correct |
4 |
Correct |
43 ms |
11316 KB |
Output is correct |
5 |
Correct |
62 ms |
14076 KB |
Output is correct |
6 |
Correct |
62 ms |
14292 KB |
Output is correct |
7 |
Correct |
46 ms |
13396 KB |
Output is correct |
8 |
Correct |
45 ms |
13148 KB |
Output is correct |
9 |
Correct |
62 ms |
14284 KB |
Output is correct |
10 |
Correct |
63 ms |
14196 KB |
Output is correct |
11 |
Correct |
60 ms |
14292 KB |
Output is correct |
12 |
Correct |
57 ms |
14204 KB |
Output is correct |
13 |
Correct |
58 ms |
14228 KB |
Output is correct |
14 |
Correct |
57 ms |
14288 KB |
Output is correct |
15 |
Correct |
60 ms |
14068 KB |
Output is correct |
16 |
Correct |
64 ms |
14280 KB |
Output is correct |
17 |
Correct |
55 ms |
13820 KB |
Output is correct |
18 |
Correct |
55 ms |
14040 KB |
Output is correct |
19 |
Correct |
56 ms |
13900 KB |
Output is correct |
20 |
Correct |
57 ms |
13820 KB |
Output is correct |
21 |
Correct |
74 ms |
13940 KB |
Output is correct |
22 |
Correct |
59 ms |
13820 KB |
Output is correct |
23 |
Correct |
43 ms |
11484 KB |
Output is correct |
24 |
Correct |
46 ms |
11840 KB |
Output is correct |
25 |
Correct |
48 ms |
12232 KB |
Output is correct |
26 |
Correct |
54 ms |
11968 KB |
Output is correct |
27 |
Correct |
53 ms |
12680 KB |
Output is correct |
28 |
Correct |
53 ms |
12796 KB |
Output is correct |
29 |
Correct |
56 ms |
12904 KB |
Output is correct |
30 |
Correct |
52 ms |
12920 KB |
Output is correct |
31 |
Correct |
41 ms |
11388 KB |
Output is correct |
32 |
Correct |
43 ms |
11620 KB |
Output is correct |
33 |
Correct |
45 ms |
11772 KB |
Output is correct |
34 |
Correct |
44 ms |
11964 KB |
Output is correct |
35 |
Incorrect |
51 ms |
12728 KB |
Wrong Answer [6] |
36 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
11388 KB |
Output is correct |
2 |
Correct |
53 ms |
12432 KB |
Output is correct |
3 |
Correct |
1 ms |
1536 KB |
Output is correct |
4 |
Correct |
37 ms |
11256 KB |
Output is correct |
5 |
Correct |
57 ms |
14068 KB |
Output is correct |
6 |
Correct |
63 ms |
14196 KB |
Output is correct |
7 |
Correct |
46 ms |
13308 KB |
Output is correct |
8 |
Correct |
45 ms |
13084 KB |
Output is correct |
9 |
Correct |
57 ms |
14208 KB |
Output is correct |
10 |
Correct |
58 ms |
14196 KB |
Output is correct |
11 |
Correct |
60 ms |
14292 KB |
Output is correct |
12 |
Correct |
60 ms |
14288 KB |
Output is correct |
13 |
Correct |
59 ms |
14068 KB |
Output is correct |
14 |
Correct |
63 ms |
14220 KB |
Output is correct |
15 |
Incorrect |
55 ms |
14196 KB |
Wrong Answer [6] |
16 |
Halted |
0 ms |
0 KB |
- |