#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
int d[20005], c[20005], e[20005], p[20005];
vector<int> adj[20005];
queue<int> q;
void dfs(int u)
{
for (int v:adj[u])
{
if (v==p[u])
continue;
p[v]=u;
c[v]=!c[u];
if (adj[v].size()>=3)
dfs(v);
else
q.push(v);
}
}
void dfs2(int u)
{
for (int v:adj[u])
{
if (v==p[u])
continue;
p[v]=u;
e[v]=(e[u]+1)%6;
if (e[v]==2 || e[v]==4 || e[v]==5)
c[v]=1;
if (adj[v].size()>=3)
q.push(v);
else
dfs2(v);
}
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V)
{
for (int i=0; i<M; i++)
{
adj[U[i]].push_back(V[i]);
adj[V[i]].push_back(U[i]);
}
if (A>2)
{
d[0]=1;
q.push(0);
while (!q.empty())
{
int u=q.front();
q.pop();
for (int v:adj[u])
{
if (!d[v])
{
d[v]=d[u]+1;
q.push(v);
}
}
}
vector<int> ans;
for (int i=0; i<M; i++)
ans.push_back(min(d[U[i]], d[V[i]])%3);
return ans;
}
q.push(0);
while (!q.empty())
{
int u=q.front();
q.pop();
if ((u==0 && adj[u].size()>=2) || adj[u].size()>=3)
dfs(u);
else
{
if (c[u])
e[u]=5;
dfs2(u);
}
}
vector<int> ans;
for (int i=0; i<M; i++)
{
if (U[i]==p[V[i]])
ans.push_back(c[V[i]]);
else
ans.push_back(c[U[i]]);
//cout << ans[i] << ' ';
}
//cout << '\n';
return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
int a, pre=2, ok;
vector<int> vec;
void Init(int A, int B)
{
a=A;
}
int Move(vector<int> y)
{
if (a>2)
{
if (y[0] && !y[2])
return 0;
else if (y[1] && !y[0])
return 1;
else
return 2;
}
if (pre==2)
{
if (y[0]+y[1]==1 || y[0]+y[1]>=3)
{
ok=1;
if (y[0]==1)
{
pre=0;
return 0;
}
else
{
pre=1;
return 1;
}
}
else
{
if (y[0]==2)
{
vec.push_back(0);
//cout << "vec push " << vec[0] << '\n';
pre=0;
return 0;
}
else if (y[1]==2)
{
vec.push_back(1);
//cout << "vec push " << vec[0] << '\n';
pre=1;
return 1;
}
else
{
vec.push_back(1);
//cout << "vec push " << vec[0] << '\n';
pre=0;
return 0;
}
}
}
else
{
if (y[0]+y[1]==0)
{
//cout << "im here 1\n";
ok=1;
return -1;
}
else if (y[0]+y[1]>=2)
{
//cout << "im here 2\n";
ok=1;
if (!y[0] || !y[1])
return -1;
y[pre]++;
if (y[0]==1)
{
pre=0;
return 0;
}
else
{
pre=1;
return 1;
}
}
else if (ok)
{
//cout << "im here 3\n";
if (y[0]==1)
{
pre=0;
return 0;
}
else
{
pre=1;
return 1;
}
}
else
{
vec.push_back(pre);
//cout << "vec push " << pre << '\n';
if (vec.size()==4)
{
ok=1;
if (y[0])
vec.push_back(0);
else
vec.push_back(1);
if ((vec[0]==0 && vec[1]==0 && vec[2]==1 && vec[3]==0 && vec[4]==1) ||
(vec[0]==0 && vec[1]==1 && vec[2]==0 && vec[3]==1 && vec[4]==1) ||
(vec[0]==1 && vec[1]==0 && vec[2]==1 && vec[3]==1 && vec[4]==0) ||
(vec[0]==0 && vec[1]==1 && vec[2]==1 && vec[3]==0 && vec[4]==0) ||
(vec[0]==1 && vec[1]==1 && vec[2]==0 && vec[3]==0 && vec[4]==1) ||
(vec[0]==1 && vec[1]==0 && vec[2]==0 && vec[3]==1 && vec[4]==0))
return -1;
else
{
if (y[0])
{
pre=0;
return 0;
}
else
{
pre=1;
return 1;
}
}
}
else
{
if (y[0])
{
pre=0;
return 0;
}
else
{
pre=1;
return 1;
}
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
15732 KB |
Output is correct |
2 |
Correct |
1 ms |
1304 KB |
Output is correct |
3 |
Correct |
22 ms |
14940 KB |
Output is correct |
4 |
Correct |
33 ms |
16764 KB |
Output is correct |
5 |
Correct |
32 ms |
16720 KB |
Output is correct |
6 |
Correct |
27 ms |
15736 KB |
Output is correct |
7 |
Correct |
25 ms |
15484 KB |
Output is correct |
8 |
Correct |
33 ms |
16000 KB |
Output is correct |
9 |
Correct |
39 ms |
16252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
15732 KB |
Output is correct |
2 |
Correct |
1 ms |
1304 KB |
Output is correct |
3 |
Correct |
22 ms |
14940 KB |
Output is correct |
4 |
Correct |
33 ms |
16764 KB |
Output is correct |
5 |
Correct |
32 ms |
16720 KB |
Output is correct |
6 |
Correct |
27 ms |
15736 KB |
Output is correct |
7 |
Correct |
25 ms |
15484 KB |
Output is correct |
8 |
Correct |
33 ms |
16000 KB |
Output is correct |
9 |
Correct |
39 ms |
16252 KB |
Output is correct |
10 |
Correct |
27 ms |
13952 KB |
Output is correct |
11 |
Correct |
23 ms |
13560 KB |
Output is correct |
12 |
Correct |
25 ms |
13680 KB |
Output is correct |
13 |
Correct |
34 ms |
13676 KB |
Output is correct |
14 |
Correct |
26 ms |
13620 KB |
Output is correct |
15 |
Correct |
40 ms |
14336 KB |
Output is correct |
16 |
Correct |
32 ms |
16248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
13172 KB |
Output is correct |
2 |
Correct |
0 ms |
1308 KB |
Output is correct |
3 |
Correct |
22 ms |
12808 KB |
Output is correct |
4 |
Correct |
44 ms |
14628 KB |
Output is correct |
5 |
Correct |
29 ms |
14696 KB |
Output is correct |
6 |
Correct |
24 ms |
13192 KB |
Output is correct |
7 |
Correct |
27 ms |
13176 KB |
Output is correct |
8 |
Correct |
28 ms |
13992 KB |
Output is correct |
9 |
Correct |
36 ms |
13732 KB |
Output is correct |
10 |
Correct |
28 ms |
13688 KB |
Output is correct |
11 |
Correct |
28 ms |
13688 KB |
Output is correct |
12 |
Correct |
36 ms |
13620 KB |
Output is correct |
13 |
Correct |
27 ms |
13732 KB |
Output is correct |
14 |
Correct |
28 ms |
13948 KB |
Output is correct |
15 |
Correct |
30 ms |
13940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
13172 KB |
Output is correct |
2 |
Correct |
0 ms |
1308 KB |
Output is correct |
3 |
Correct |
22 ms |
12808 KB |
Output is correct |
4 |
Correct |
44 ms |
14628 KB |
Output is correct |
5 |
Correct |
29 ms |
14696 KB |
Output is correct |
6 |
Correct |
24 ms |
13192 KB |
Output is correct |
7 |
Correct |
27 ms |
13176 KB |
Output is correct |
8 |
Correct |
28 ms |
13992 KB |
Output is correct |
9 |
Correct |
36 ms |
13732 KB |
Output is correct |
10 |
Correct |
28 ms |
13688 KB |
Output is correct |
11 |
Correct |
28 ms |
13688 KB |
Output is correct |
12 |
Correct |
36 ms |
13620 KB |
Output is correct |
13 |
Correct |
27 ms |
13732 KB |
Output is correct |
14 |
Correct |
28 ms |
13948 KB |
Output is correct |
15 |
Correct |
30 ms |
13940 KB |
Output is correct |
16 |
Correct |
24 ms |
11628 KB |
Output is correct |
17 |
Correct |
26 ms |
11700 KB |
Output is correct |
18 |
Correct |
26 ms |
11752 KB |
Output is correct |
19 |
Correct |
21 ms |
11644 KB |
Output is correct |
20 |
Correct |
32 ms |
12408 KB |
Output is correct |
21 |
Correct |
24 ms |
12156 KB |
Output is correct |
22 |
Correct |
26 ms |
14200 KB |
Output is correct |
23 |
Correct |
30 ms |
11896 KB |
Output is correct |
24 |
Correct |
32 ms |
11880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1568 KB |
Output is correct |
2 |
Correct |
1 ms |
1312 KB |
Output is correct |
3 |
Correct |
1 ms |
1564 KB |
Output is correct |
4 |
Correct |
3 ms |
1564 KB |
Output is correct |
5 |
Correct |
2 ms |
1816 KB |
Output is correct |
6 |
Correct |
2 ms |
1560 KB |
Output is correct |
7 |
Correct |
2 ms |
1564 KB |
Output is correct |
8 |
Correct |
1 ms |
1572 KB |
Output is correct |
9 |
Correct |
2 ms |
1572 KB |
Output is correct |
10 |
Correct |
2 ms |
1564 KB |
Output is correct |
11 |
Correct |
1 ms |
1572 KB |
Output is correct |
12 |
Correct |
1 ms |
1564 KB |
Output is correct |
13 |
Correct |
1 ms |
1572 KB |
Output is correct |
14 |
Correct |
2 ms |
1568 KB |
Output is correct |
15 |
Correct |
1 ms |
1572 KB |
Output is correct |
16 |
Correct |
2 ms |
1564 KB |
Output is correct |
17 |
Correct |
1 ms |
1576 KB |
Output is correct |
18 |
Correct |
1 ms |
1564 KB |
Output is correct |
19 |
Correct |
2 ms |
1576 KB |
Output is correct |
20 |
Correct |
1 ms |
1572 KB |
Output is correct |
21 |
Correct |
2 ms |
1564 KB |
Output is correct |
22 |
Correct |
2 ms |
1564 KB |
Output is correct |
23 |
Correct |
2 ms |
1572 KB |
Output is correct |
24 |
Correct |
1 ms |
1748 KB |
Output is correct |
25 |
Correct |
2 ms |
1568 KB |
Output is correct |
26 |
Correct |
1 ms |
1572 KB |
Output is correct |
27 |
Correct |
2 ms |
1564 KB |
Output is correct |
28 |
Correct |
2 ms |
1564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
11648 KB |
Output is correct |
2 |
Correct |
35 ms |
12116 KB |
Output is correct |
3 |
Correct |
0 ms |
1300 KB |
Output is correct |
4 |
Correct |
21 ms |
11632 KB |
Output is correct |
5 |
Correct |
28 ms |
15184 KB |
Output is correct |
6 |
Correct |
33 ms |
15148 KB |
Output is correct |
7 |
Correct |
24 ms |
14160 KB |
Output is correct |
8 |
Correct |
28 ms |
14300 KB |
Output is correct |
9 |
Correct |
32 ms |
14988 KB |
Output is correct |
10 |
Correct |
26 ms |
15056 KB |
Output is correct |
11 |
Correct |
27 ms |
15128 KB |
Output is correct |
12 |
Correct |
27 ms |
15184 KB |
Output is correct |
13 |
Correct |
33 ms |
15020 KB |
Output is correct |
14 |
Correct |
31 ms |
15140 KB |
Output is correct |
15 |
Correct |
30 ms |
15424 KB |
Output is correct |
16 |
Correct |
34 ms |
14968 KB |
Output is correct |
17 |
Correct |
27 ms |
14972 KB |
Output is correct |
18 |
Correct |
36 ms |
14912 KB |
Output is correct |
19 |
Correct |
30 ms |
14584 KB |
Output is correct |
20 |
Correct |
34 ms |
14924 KB |
Output is correct |
21 |
Correct |
30 ms |
14876 KB |
Output is correct |
22 |
Correct |
26 ms |
14936 KB |
Output is correct |
23 |
Correct |
20 ms |
12116 KB |
Output is correct |
24 |
Correct |
23 ms |
12108 KB |
Output is correct |
25 |
Correct |
27 ms |
12520 KB |
Output is correct |
26 |
Correct |
22 ms |
12480 KB |
Output is correct |
27 |
Correct |
26 ms |
12536 KB |
Output is correct |
28 |
Correct |
33 ms |
12304 KB |
Output is correct |
29 |
Correct |
31 ms |
12540 KB |
Output is correct |
30 |
Correct |
25 ms |
12544 KB |
Output is correct |
31 |
Correct |
20 ms |
12128 KB |
Output is correct |
32 |
Correct |
35 ms |
12128 KB |
Output is correct |
33 |
Correct |
27 ms |
12444 KB |
Output is correct |
34 |
Correct |
23 ms |
12372 KB |
Output is correct |
35 |
Correct |
32 ms |
12436 KB |
Output is correct |
36 |
Correct |
30 ms |
12364 KB |
Output is correct |
37 |
Correct |
25 ms |
12344 KB |
Output is correct |
38 |
Correct |
24 ms |
12284 KB |
Output is correct |
39 |
Correct |
25 ms |
12540 KB |
Output is correct |
40 |
Correct |
32 ms |
12376 KB |
Output is correct |
41 |
Correct |
28 ms |
13424 KB |
Output is correct |
42 |
Correct |
26 ms |
13440 KB |
Output is correct |
43 |
Correct |
26 ms |
13392 KB |
Output is correct |
44 |
Correct |
25 ms |
13404 KB |
Output is correct |
45 |
Correct |
26 ms |
13400 KB |
Output is correct |
46 |
Correct |
28 ms |
13392 KB |
Output is correct |
47 |
Correct |
27 ms |
12608 KB |
Output is correct |
48 |
Correct |
24 ms |
12628 KB |
Output is correct |
49 |
Correct |
26 ms |
12632 KB |
Output is correct |
50 |
Correct |
27 ms |
12700 KB |
Output is correct |
51 |
Correct |
24 ms |
12092 KB |
Output is correct |
52 |
Correct |
28 ms |
12352 KB |
Output is correct |
53 |
Correct |
28 ms |
12204 KB |
Output is correct |
54 |
Correct |
24 ms |
12112 KB |
Output is correct |
55 |
Correct |
28 ms |
12188 KB |
Output is correct |
56 |
Correct |
22 ms |
12116 KB |
Output is correct |
57 |
Correct |
23 ms |
12180 KB |
Output is correct |
58 |
Correct |
24 ms |
12244 KB |
Output is correct |
59 |
Correct |
22 ms |
12160 KB |
Output is correct |
60 |
Correct |
23 ms |
12032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
11536 KB |
Output is correct |
2 |
Correct |
31 ms |
12064 KB |
Output is correct |
3 |
Correct |
0 ms |
1312 KB |
Output is correct |
4 |
Correct |
20 ms |
11836 KB |
Output is correct |
5 |
Correct |
41 ms |
14980 KB |
Output is correct |
6 |
Correct |
36 ms |
15196 KB |
Output is correct |
7 |
Correct |
28 ms |
14156 KB |
Output is correct |
8 |
Correct |
26 ms |
14132 KB |
Output is correct |
9 |
Correct |
26 ms |
15004 KB |
Output is correct |
10 |
Correct |
27 ms |
15188 KB |
Output is correct |
11 |
Correct |
42 ms |
15220 KB |
Output is correct |
12 |
Correct |
56 ms |
15412 KB |
Output is correct |
13 |
Correct |
33 ms |
15116 KB |
Output is correct |
14 |
Correct |
33 ms |
14980 KB |
Output is correct |
15 |
Correct |
47 ms |
15028 KB |
Output is correct |
16 |
Correct |
26 ms |
15168 KB |
Output is correct |
17 |
Correct |
28 ms |
14880 KB |
Output is correct |
18 |
Correct |
27 ms |
14932 KB |
Output is correct |
19 |
Correct |
30 ms |
14828 KB |
Output is correct |
20 |
Correct |
26 ms |
14744 KB |
Output is correct |
21 |
Correct |
26 ms |
14928 KB |
Output is correct |
22 |
Correct |
41 ms |
14932 KB |
Output is correct |
23 |
Correct |
25 ms |
11984 KB |
Output is correct |
24 |
Correct |
24 ms |
12032 KB |
Output is correct |
25 |
Correct |
33 ms |
12676 KB |
Output is correct |
26 |
Correct |
24 ms |
12488 KB |
Output is correct |
27 |
Correct |
25 ms |
12508 KB |
Output is correct |
28 |
Correct |
28 ms |
12428 KB |
Output is correct |
29 |
Correct |
27 ms |
12612 KB |
Output is correct |
30 |
Correct |
27 ms |
12580 KB |
Output is correct |
31 |
Correct |
27 ms |
12052 KB |
Output is correct |
32 |
Correct |
24 ms |
12080 KB |
Output is correct |
33 |
Correct |
28 ms |
12356 KB |
Output is correct |
34 |
Correct |
26 ms |
12660 KB |
Output is correct |
35 |
Correct |
36 ms |
12224 KB |
Output is correct |
36 |
Correct |
25 ms |
12352 KB |
Output is correct |
37 |
Correct |
33 ms |
12208 KB |
Output is correct |
38 |
Correct |
30 ms |
12192 KB |
Output is correct |
39 |
Correct |
26 ms |
12608 KB |
Output is correct |
40 |
Correct |
27 ms |
12348 KB |
Output is correct |
41 |
Correct |
30 ms |
13500 KB |
Output is correct |
42 |
Correct |
32 ms |
13260 KB |
Output is correct |
43 |
Correct |
28 ms |
13348 KB |
Output is correct |
44 |
Correct |
34 ms |
13220 KB |
Output is correct |
45 |
Correct |
28 ms |
13288 KB |
Output is correct |
46 |
Correct |
26 ms |
13392 KB |
Output is correct |
47 |
Correct |
24 ms |
12628 KB |
Output is correct |
48 |
Correct |
37 ms |
12824 KB |
Output is correct |
49 |
Correct |
37 ms |
12540 KB |
Output is correct |
50 |
Correct |
27 ms |
12892 KB |
Output is correct |
51 |
Correct |
22 ms |
12108 KB |
Output is correct |
52 |
Correct |
28 ms |
12188 KB |
Output is correct |
53 |
Correct |
25 ms |
12120 KB |
Output is correct |
54 |
Correct |
25 ms |
12224 KB |
Output is correct |
55 |
Correct |
22 ms |
12116 KB |
Output is correct |
56 |
Correct |
31 ms |
12180 KB |
Output is correct |
57 |
Correct |
24 ms |
12348 KB |
Output is correct |
58 |
Correct |
23 ms |
12124 KB |
Output is correct |
59 |
Correct |
23 ms |
12116 KB |
Output is correct |
60 |
Correct |
24 ms |
12088 KB |
Output is correct |