#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)
p.push_back(b);
return l=b;
}
if (!y[0] && !y[1])
{
p.clear();
return -1;
}
if (p.size()==6)
{
for (int i=0;i<6;i++)
{
bool eq=1;
for (int j=0;j<6;j++)
eq&=(p[(i+j)%6]==seq[j]);
if (eq)
{
p.clear();
return -1;
}
}
}
if (y[0]+y[1]==1)
{
p.push_back(y[1]);
return l=y[1];
}
p.clear();
if (!y[l])
return -1;
l^=1;
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
15808 KB |
Output is correct |
2 |
Correct |
2 ms |
1792 KB |
Output is correct |
3 |
Correct |
41 ms |
15464 KB |
Output is correct |
4 |
Correct |
64 ms |
17232 KB |
Output is correct |
5 |
Correct |
64 ms |
17100 KB |
Output is correct |
6 |
Correct |
54 ms |
15952 KB |
Output is correct |
7 |
Correct |
49 ms |
15952 KB |
Output is correct |
8 |
Correct |
59 ms |
16628 KB |
Output is correct |
9 |
Correct |
60 ms |
16616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
15808 KB |
Output is correct |
2 |
Correct |
2 ms |
1792 KB |
Output is correct |
3 |
Correct |
41 ms |
15464 KB |
Output is correct |
4 |
Correct |
64 ms |
17232 KB |
Output is correct |
5 |
Correct |
64 ms |
17100 KB |
Output is correct |
6 |
Correct |
54 ms |
15952 KB |
Output is correct |
7 |
Correct |
49 ms |
15952 KB |
Output is correct |
8 |
Correct |
59 ms |
16628 KB |
Output is correct |
9 |
Correct |
60 ms |
16616 KB |
Output is correct |
10 |
Correct |
52 ms |
14024 KB |
Output is correct |
11 |
Correct |
45 ms |
14064 KB |
Output is correct |
12 |
Correct |
47 ms |
14148 KB |
Output is correct |
13 |
Correct |
46 ms |
13900 KB |
Output is correct |
14 |
Correct |
50 ms |
14544 KB |
Output is correct |
15 |
Correct |
54 ms |
14540 KB |
Output is correct |
16 |
Correct |
57 ms |
16920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
13384 KB |
Output is correct |
2 |
Correct |
1 ms |
2048 KB |
Output is correct |
3 |
Correct |
39 ms |
12924 KB |
Output is correct |
4 |
Correct |
62 ms |
14760 KB |
Output is correct |
5 |
Correct |
61 ms |
14632 KB |
Output is correct |
6 |
Correct |
47 ms |
13360 KB |
Output is correct |
7 |
Correct |
47 ms |
13356 KB |
Output is correct |
8 |
Correct |
57 ms |
14176 KB |
Output is correct |
9 |
Correct |
56 ms |
14176 KB |
Output is correct |
10 |
Correct |
53 ms |
13684 KB |
Output is correct |
11 |
Correct |
52 ms |
13812 KB |
Output is correct |
12 |
Correct |
52 ms |
13916 KB |
Output is correct |
13 |
Correct |
55 ms |
13752 KB |
Output is correct |
14 |
Correct |
54 ms |
14172 KB |
Output is correct |
15 |
Correct |
56 ms |
13948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
13384 KB |
Output is correct |
2 |
Correct |
1 ms |
2048 KB |
Output is correct |
3 |
Correct |
39 ms |
12924 KB |
Output is correct |
4 |
Correct |
62 ms |
14760 KB |
Output is correct |
5 |
Correct |
61 ms |
14632 KB |
Output is correct |
6 |
Correct |
47 ms |
13360 KB |
Output is correct |
7 |
Correct |
47 ms |
13356 KB |
Output is correct |
8 |
Correct |
57 ms |
14176 KB |
Output is correct |
9 |
Correct |
56 ms |
14176 KB |
Output is correct |
10 |
Correct |
53 ms |
13684 KB |
Output is correct |
11 |
Correct |
52 ms |
13812 KB |
Output is correct |
12 |
Correct |
52 ms |
13916 KB |
Output is correct |
13 |
Correct |
55 ms |
13752 KB |
Output is correct |
14 |
Correct |
54 ms |
14172 KB |
Output is correct |
15 |
Correct |
56 ms |
13948 KB |
Output is correct |
16 |
Correct |
44 ms |
11760 KB |
Output is correct |
17 |
Correct |
41 ms |
11828 KB |
Output is correct |
18 |
Correct |
47 ms |
11672 KB |
Output is correct |
19 |
Correct |
43 ms |
11872 KB |
Output is correct |
20 |
Correct |
51 ms |
12388 KB |
Output is correct |
21 |
Correct |
48 ms |
12256 KB |
Output is correct |
22 |
Correct |
57 ms |
14068 KB |
Output is correct |
23 |
Correct |
45 ms |
12004 KB |
Output is correct |
24 |
Correct |
47 ms |
12100 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 |
2 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 |
1792 KB |
Output is correct |
17 |
Correct |
2 ms |
2048 KB |
Output is correct |
18 |
Correct |
2 ms |
1536 KB |
Output is correct |
19 |
Correct |
2 ms |
1536 KB |
Output is correct |
20 |
Correct |
2 ms |
1536 KB |
Output is correct |
21 |
Correct |
2 ms |
1792 KB |
Output is correct |
22 |
Correct |
2 ms |
1536 KB |
Output is correct |
23 |
Correct |
2 ms |
1792 KB |
Output is correct |
24 |
Correct |
2 ms |
1792 KB |
Output is correct |
25 |
Correct |
2 ms |
1536 KB |
Output is correct |
26 |
Correct |
2 ms |
1792 KB |
Output is correct |
27 |
Correct |
2 ms |
1536 KB |
Output is correct |
28 |
Correct |
2 ms |
1792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
11408 KB |
Output is correct |
2 |
Correct |
49 ms |
12544 KB |
Output is correct |
3 |
Correct |
1 ms |
1536 KB |
Output is correct |
4 |
Correct |
39 ms |
11128 KB |
Output is correct |
5 |
Correct |
57 ms |
14416 KB |
Output is correct |
6 |
Correct |
58 ms |
14244 KB |
Output is correct |
7 |
Correct |
47 ms |
13432 KB |
Output is correct |
8 |
Correct |
45 ms |
13404 KB |
Output is correct |
9 |
Correct |
56 ms |
14280 KB |
Output is correct |
10 |
Correct |
62 ms |
14252 KB |
Output is correct |
11 |
Correct |
57 ms |
14292 KB |
Output is correct |
12 |
Correct |
59 ms |
14060 KB |
Output is correct |
13 |
Correct |
59 ms |
14292 KB |
Output is correct |
14 |
Correct |
64 ms |
14196 KB |
Output is correct |
15 |
Correct |
57 ms |
14196 KB |
Output is correct |
16 |
Correct |
58 ms |
14292 KB |
Output is correct |
17 |
Correct |
56 ms |
13764 KB |
Output is correct |
18 |
Correct |
56 ms |
13896 KB |
Output is correct |
19 |
Correct |
62 ms |
13812 KB |
Output is correct |
20 |
Correct |
55 ms |
14036 KB |
Output is correct |
21 |
Correct |
54 ms |
13908 KB |
Output is correct |
22 |
Correct |
56 ms |
14032 KB |
Output is correct |
23 |
Correct |
44 ms |
11492 KB |
Output is correct |
24 |
Correct |
43 ms |
11388 KB |
Output is correct |
25 |
Correct |
46 ms |
11984 KB |
Output is correct |
26 |
Correct |
45 ms |
11988 KB |
Output is correct |
27 |
Correct |
57 ms |
12800 KB |
Output is correct |
28 |
Correct |
52 ms |
12668 KB |
Output is correct |
29 |
Correct |
52 ms |
12796 KB |
Output is correct |
30 |
Correct |
52 ms |
13032 KB |
Output is correct |
31 |
Correct |
44 ms |
11620 KB |
Output is correct |
32 |
Correct |
46 ms |
11620 KB |
Output is correct |
33 |
Correct |
44 ms |
11836 KB |
Output is correct |
34 |
Correct |
44 ms |
11900 KB |
Output is correct |
35 |
Correct |
51 ms |
12732 KB |
Output is correct |
36 |
Correct |
50 ms |
12752 KB |
Output is correct |
37 |
Correct |
51 ms |
12744 KB |
Output is correct |
38 |
Correct |
53 ms |
12536 KB |
Output is correct |
39 |
Correct |
54 ms |
12540 KB |
Output is correct |
40 |
Correct |
49 ms |
12744 KB |
Output is correct |
41 |
Correct |
54 ms |
13432 KB |
Output is correct |
42 |
Correct |
55 ms |
13296 KB |
Output is correct |
43 |
Correct |
54 ms |
13412 KB |
Output is correct |
44 |
Correct |
55 ms |
13412 KB |
Output is correct |
45 |
Correct |
54 ms |
13548 KB |
Output is correct |
46 |
Correct |
53 ms |
13428 KB |
Output is correct |
47 |
Correct |
51 ms |
12660 KB |
Output is correct |
48 |
Correct |
49 ms |
12412 KB |
Output is correct |
49 |
Correct |
49 ms |
12320 KB |
Output is correct |
50 |
Correct |
51 ms |
12412 KB |
Output is correct |
51 |
Correct |
48 ms |
11772 KB |
Output is correct |
52 |
Correct |
48 ms |
11820 KB |
Output is correct |
53 |
Correct |
47 ms |
12076 KB |
Output is correct |
54 |
Correct |
50 ms |
11816 KB |
Output is correct |
55 |
Correct |
45 ms |
11828 KB |
Output is correct |
56 |
Correct |
45 ms |
11772 KB |
Output is correct |
57 |
Correct |
45 ms |
11772 KB |
Output is correct |
58 |
Correct |
48 ms |
11848 KB |
Output is correct |
59 |
Correct |
46 ms |
11740 KB |
Output is correct |
60 |
Correct |
46 ms |
11736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
11484 KB |
Output is correct |
2 |
Correct |
47 ms |
12412 KB |
Output is correct |
3 |
Correct |
2 ms |
1536 KB |
Output is correct |
4 |
Correct |
37 ms |
11128 KB |
Output is correct |
5 |
Correct |
56 ms |
14288 KB |
Output is correct |
6 |
Correct |
58 ms |
14416 KB |
Output is correct |
7 |
Correct |
47 ms |
13560 KB |
Output is correct |
8 |
Correct |
46 ms |
13396 KB |
Output is correct |
9 |
Correct |
61 ms |
14276 KB |
Output is correct |
10 |
Correct |
63 ms |
14376 KB |
Output is correct |
11 |
Correct |
66 ms |
14196 KB |
Output is correct |
12 |
Correct |
59 ms |
14288 KB |
Output is correct |
13 |
Correct |
57 ms |
14204 KB |
Output is correct |
14 |
Correct |
60 ms |
14196 KB |
Output is correct |
15 |
Incorrect |
56 ms |
14288 KB |
Wrong Answer [6] |
16 |
Halted |
0 ms |
0 KB |
- |