// M
#include<bits/stdc++.h>
#include "Anthony.h"
using namespace std;
const int N = 21234;
int D[N];
vector < int > Adj[N];
vector < pair < int , int > > Ad[N];
vector < int > Sub(int n, int m, int A, int B, vector < int > U, vector < int > V)
{
assert(B == 0 && A >= 3);
for (int i = 0; i < m; i ++)
Adj[U[i]].push_back(V[i]), Adj[V[i]].push_back(U[i]);
memset(D, -1, sizeof(D));
queue < int > qu;
qu.push(0); D[0] = 0;
while (qu.size())
{
int v = qu.front();
qu.pop();
for (int u : Adj[v])
if (D[u] == -1)
D[u] = D[v] + 1, qu.push(u);
}
vector < int > C(m, 0);
for (int i = 0; i < m; i ++)
{
int d = min(D[V[i]], D[U[i]]);
C[i] = d % 3;
}
return C;
}
int C[N];
int gx[] = {1, 1, 0, 0, 1, 0};
vector < int > RS;
void DFS(int v, int p, int cc = 0)
{
for (int i = 0; i < (int)Ad[v].size(); i ++)
if (Ad[v][i].first == p)
Ad[v].erase(Ad[v].begin() + i);
if (!Ad[v].size())
return ;
if (Ad[v].size() > 1)
{
for (auto u : Ad[v])
C[u.first] = !C[v], RS[u.second] = !C[v], DFS(u.first, v, 0);
return ;
}
if (Ad[v].size() == 1)
{
C[Ad[v][0].first] = gx[cc];
RS[Ad[v][0].second] = gx[cc];
DFS(Ad[v][0].first, v, (cc + 1) % 6);
return ;
}
}
vector < int > Mark(int n, int m, int A, int B, vector < int > U, vector < int > V)
{
if (B == 0)
return Sub(n, m, A, B, U, V);
assert(A == 2);
for (int i = 0; i < m; i ++)
Ad[U[i]].push_back({V[i], i}), Ad[V[i]].push_back({U[i], i});
RS = vector < int >(m, 0);
DFS(0, -1);
return RS;
}
// M
#include<bits/stdc++.h>
#define prev lolololol
#include "Catherine.h"
using namespace std;
const int N = 21234;
int cA, cB;
int prev = -1, Found = 0;
vector < int > Cur;
vector < vector < int > > vec;
void Init(int A, int B)
{
cA = A;
cB = B;
prev = -1;
Found = 0;
vec.push_back({1, 1, 0, 1, 1, 0});
vec.push_back({1, 1, 1, 0, 1, 1});
vec.push_back({1, 1, 1, 1, 0, 0});
vec.push_back({0, 2, 1, 0, 0, 1});
vec.push_back({1, 1, 0, 0, 1, 0});
vec.push_back({2, 0, 0, 1, 0, 1});
}
int Move2(vector < int > Freq)
{
assert(cB == 0 && cA >= 3);
int c = 0;
for (int a : Freq)
if (a) c ++;
if (c == 1 && Freq[0])
return 0;
if (c == 1 && Freq[1])
return 1;
if (c == 1 && Freq[2])
return 2;
assert(c == 2);
if (Freq[0] && Freq[1])
return 0;
if (Freq[0])
return 2;
return 1;
}
int Move(vector < int > Freq)
{
if (cB == 0)
return Move2(Freq);
assert(cA == 2);
int dg = Freq[0] + Freq[1];
if (prev != -1) dg ++;
assert(dg);
if (dg == 1)
{
Found = 1;
if (prev != -1)
return -1;
prev = Freq[0] ? 0 : 1;
return prev;
}
if (dg > 2)
{
Found = 1;
int togo = ((Freq[1] + (prev == 1)) == 1);
if (prev == togo)
return -1;
return prev = togo;
}
if (Found)
return prev = (Freq[1] == 1);
if (!Cur.size())
{
Cur.push_back(Freq[0]);
Cur.push_back(Freq[1]);
Cur.push_back(Freq[1] > 0);
return prev = Freq[1] ? 1 : 0;
}
Cur.push_back(Freq[1] == 1);
if (Cur.size() < 6)
return prev = (Freq[1] == 1);
assert(Cur.size() == 6);
bool ff = 0;
for (auto v : vec)
ff |= (Cur == v);
if (Cur[2] == 1 && Cur[3] == 1 && Cur[4] == 0 && Cur[5] == 0)
ff = 1;
Found = 1;
if (ff)
return -1;
return prev = (Freq[1] == 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
16292 KB |
Output is correct |
2 |
Correct |
1 ms |
2816 KB |
Output is correct |
3 |
Correct |
45 ms |
15632 KB |
Output is correct |
4 |
Correct |
67 ms |
17460 KB |
Output is correct |
5 |
Correct |
67 ms |
17396 KB |
Output is correct |
6 |
Correct |
56 ms |
16136 KB |
Output is correct |
7 |
Correct |
54 ms |
16060 KB |
Output is correct |
8 |
Correct |
62 ms |
16936 KB |
Output is correct |
9 |
Correct |
57 ms |
16828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
16292 KB |
Output is correct |
2 |
Correct |
1 ms |
2816 KB |
Output is correct |
3 |
Correct |
45 ms |
15632 KB |
Output is correct |
4 |
Correct |
67 ms |
17460 KB |
Output is correct |
5 |
Correct |
67 ms |
17396 KB |
Output is correct |
6 |
Correct |
56 ms |
16136 KB |
Output is correct |
7 |
Correct |
54 ms |
16060 KB |
Output is correct |
8 |
Correct |
62 ms |
16936 KB |
Output is correct |
9 |
Correct |
57 ms |
16828 KB |
Output is correct |
10 |
Correct |
45 ms |
14072 KB |
Output is correct |
11 |
Correct |
45 ms |
14312 KB |
Output is correct |
12 |
Correct |
44 ms |
14328 KB |
Output is correct |
13 |
Correct |
44 ms |
14064 KB |
Output is correct |
14 |
Correct |
47 ms |
14352 KB |
Output is correct |
15 |
Correct |
53 ms |
14756 KB |
Output is correct |
16 |
Correct |
55 ms |
16972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
13876 KB |
Output is correct |
2 |
Correct |
1 ms |
2816 KB |
Output is correct |
3 |
Correct |
41 ms |
13516 KB |
Output is correct |
4 |
Correct |
61 ms |
15292 KB |
Output is correct |
5 |
Correct |
65 ms |
15100 KB |
Output is correct |
6 |
Correct |
48 ms |
13856 KB |
Output is correct |
7 |
Correct |
47 ms |
13868 KB |
Output is correct |
8 |
Correct |
61 ms |
14440 KB |
Output is correct |
9 |
Correct |
63 ms |
14580 KB |
Output is correct |
10 |
Correct |
50 ms |
14384 KB |
Output is correct |
11 |
Correct |
51 ms |
14332 KB |
Output is correct |
12 |
Correct |
51 ms |
14380 KB |
Output is correct |
13 |
Correct |
53 ms |
14204 KB |
Output is correct |
14 |
Correct |
59 ms |
14580 KB |
Output is correct |
15 |
Correct |
58 ms |
14672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
13876 KB |
Output is correct |
2 |
Correct |
1 ms |
2816 KB |
Output is correct |
3 |
Correct |
41 ms |
13516 KB |
Output is correct |
4 |
Correct |
61 ms |
15292 KB |
Output is correct |
5 |
Correct |
65 ms |
15100 KB |
Output is correct |
6 |
Correct |
48 ms |
13856 KB |
Output is correct |
7 |
Correct |
47 ms |
13868 KB |
Output is correct |
8 |
Correct |
61 ms |
14440 KB |
Output is correct |
9 |
Correct |
63 ms |
14580 KB |
Output is correct |
10 |
Correct |
50 ms |
14384 KB |
Output is correct |
11 |
Correct |
51 ms |
14332 KB |
Output is correct |
12 |
Correct |
51 ms |
14380 KB |
Output is correct |
13 |
Correct |
53 ms |
14204 KB |
Output is correct |
14 |
Correct |
59 ms |
14580 KB |
Output is correct |
15 |
Correct |
58 ms |
14672 KB |
Output is correct |
16 |
Correct |
41 ms |
12456 KB |
Output is correct |
17 |
Correct |
40 ms |
12324 KB |
Output is correct |
18 |
Correct |
44 ms |
12156 KB |
Output is correct |
19 |
Correct |
44 ms |
12532 KB |
Output is correct |
20 |
Correct |
56 ms |
12784 KB |
Output is correct |
21 |
Correct |
47 ms |
12648 KB |
Output is correct |
22 |
Correct |
54 ms |
14784 KB |
Output is correct |
23 |
Correct |
46 ms |
12540 KB |
Output is correct |
24 |
Correct |
50 ms |
12320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2816 KB |
Output is correct |
2 |
Correct |
1 ms |
2560 KB |
Output is correct |
3 |
Correct |
2 ms |
2816 KB |
Output is correct |
4 |
Correct |
2 ms |
2816 KB |
Output is correct |
5 |
Correct |
2 ms |
2816 KB |
Output is correct |
6 |
Correct |
3 ms |
2816 KB |
Output is correct |
7 |
Correct |
2 ms |
2816 KB |
Output is correct |
8 |
Correct |
2 ms |
2816 KB |
Output is correct |
9 |
Correct |
2 ms |
2816 KB |
Output is correct |
10 |
Correct |
2 ms |
2816 KB |
Output is correct |
11 |
Correct |
2 ms |
2816 KB |
Output is correct |
12 |
Correct |
2 ms |
2816 KB |
Output is correct |
13 |
Correct |
2 ms |
2816 KB |
Output is correct |
14 |
Correct |
2 ms |
2816 KB |
Output is correct |
15 |
Correct |
2 ms |
2816 KB |
Output is correct |
16 |
Correct |
2 ms |
2816 KB |
Output is correct |
17 |
Correct |
2 ms |
3072 KB |
Output is correct |
18 |
Correct |
2 ms |
2816 KB |
Output is correct |
19 |
Correct |
2 ms |
2816 KB |
Output is correct |
20 |
Correct |
2 ms |
2816 KB |
Output is correct |
21 |
Correct |
2 ms |
2816 KB |
Output is correct |
22 |
Correct |
2 ms |
2816 KB |
Output is correct |
23 |
Correct |
2 ms |
2816 KB |
Output is correct |
24 |
Correct |
2 ms |
2816 KB |
Output is correct |
25 |
Correct |
2 ms |
2816 KB |
Output is correct |
26 |
Correct |
2 ms |
2816 KB |
Output is correct |
27 |
Correct |
2 ms |
2816 KB |
Output is correct |
28 |
Correct |
2 ms |
2816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
11900 KB |
Output is correct |
2 |
Correct |
49 ms |
13048 KB |
Output is correct |
3 |
Correct |
1 ms |
2560 KB |
Output is correct |
4 |
Correct |
37 ms |
12072 KB |
Output is correct |
5 |
Correct |
54 ms |
13776 KB |
Output is correct |
6 |
Correct |
67 ms |
13672 KB |
Output is correct |
7 |
Correct |
45 ms |
12628 KB |
Output is correct |
8 |
Correct |
45 ms |
12800 KB |
Output is correct |
9 |
Correct |
67 ms |
13584 KB |
Output is correct |
10 |
Correct |
58 ms |
13776 KB |
Output is correct |
11 |
Correct |
65 ms |
13644 KB |
Output is correct |
12 |
Correct |
67 ms |
13516 KB |
Output is correct |
13 |
Correct |
59 ms |
13712 KB |
Output is correct |
14 |
Correct |
56 ms |
13600 KB |
Output is correct |
15 |
Correct |
57 ms |
13896 KB |
Output is correct |
16 |
Correct |
58 ms |
13700 KB |
Output is correct |
17 |
Correct |
53 ms |
13268 KB |
Output is correct |
18 |
Correct |
54 ms |
13260 KB |
Output is correct |
19 |
Correct |
56 ms |
13308 KB |
Output is correct |
20 |
Correct |
56 ms |
13328 KB |
Output is correct |
21 |
Correct |
53 ms |
13328 KB |
Output is correct |
22 |
Correct |
50 ms |
13328 KB |
Output is correct |
23 |
Correct |
43 ms |
12412 KB |
Output is correct |
24 |
Correct |
41 ms |
12416 KB |
Output is correct |
25 |
Correct |
45 ms |
12628 KB |
Output is correct |
26 |
Correct |
45 ms |
12912 KB |
Output is correct |
27 |
Correct |
51 ms |
13012 KB |
Output is correct |
28 |
Correct |
50 ms |
13184 KB |
Output is correct |
29 |
Correct |
52 ms |
13184 KB |
Output is correct |
30 |
Correct |
56 ms |
13116 KB |
Output is correct |
31 |
Correct |
43 ms |
12424 KB |
Output is correct |
32 |
Correct |
44 ms |
12432 KB |
Output is correct |
33 |
Correct |
49 ms |
12496 KB |
Output is correct |
34 |
Correct |
44 ms |
12564 KB |
Output is correct |
35 |
Correct |
50 ms |
13240 KB |
Output is correct |
36 |
Correct |
49 ms |
13056 KB |
Output is correct |
37 |
Correct |
50 ms |
13056 KB |
Output is correct |
38 |
Correct |
48 ms |
13052 KB |
Output is correct |
39 |
Correct |
57 ms |
12884 KB |
Output is correct |
40 |
Correct |
51 ms |
13012 KB |
Output is correct |
41 |
Correct |
51 ms |
13152 KB |
Output is correct |
42 |
Correct |
52 ms |
13360 KB |
Output is correct |
43 |
Correct |
54 ms |
13244 KB |
Output is correct |
44 |
Correct |
51 ms |
13140 KB |
Output is correct |
45 |
Correct |
53 ms |
13484 KB |
Output is correct |
46 |
Correct |
54 ms |
13484 KB |
Output is correct |
47 |
Correct |
50 ms |
13104 KB |
Output is correct |
48 |
Correct |
49 ms |
12876 KB |
Output is correct |
49 |
Correct |
54 ms |
12980 KB |
Output is correct |
50 |
Correct |
50 ms |
12956 KB |
Output is correct |
51 |
Correct |
47 ms |
12820 KB |
Output is correct |
52 |
Correct |
47 ms |
12868 KB |
Output is correct |
53 |
Correct |
48 ms |
12852 KB |
Output is correct |
54 |
Correct |
51 ms |
12788 KB |
Output is correct |
55 |
Correct |
46 ms |
12628 KB |
Output is correct |
56 |
Correct |
53 ms |
12628 KB |
Output is correct |
57 |
Correct |
49 ms |
12404 KB |
Output is correct |
58 |
Correct |
44 ms |
12396 KB |
Output is correct |
59 |
Correct |
44 ms |
12500 KB |
Output is correct |
60 |
Correct |
45 ms |
12500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
11900 KB |
Output is correct |
2 |
Correct |
52 ms |
12788 KB |
Output is correct |
3 |
Correct |
1 ms |
2560 KB |
Output is correct |
4 |
Correct |
37 ms |
12084 KB |
Output is correct |
5 |
Correct |
53 ms |
13576 KB |
Output is correct |
6 |
Correct |
53 ms |
13576 KB |
Output is correct |
7 |
Correct |
44 ms |
12820 KB |
Output is correct |
8 |
Correct |
46 ms |
12748 KB |
Output is correct |
9 |
Correct |
54 ms |
13524 KB |
Output is correct |
10 |
Correct |
55 ms |
13516 KB |
Output is correct |
11 |
Correct |
55 ms |
13964 KB |
Output is correct |
12 |
Correct |
55 ms |
13524 KB |
Output is correct |
13 |
Correct |
56 ms |
13592 KB |
Output is correct |
14 |
Correct |
56 ms |
13584 KB |
Output is correct |
15 |
Correct |
54 ms |
13708 KB |
Output is correct |
16 |
Correct |
55 ms |
13584 KB |
Output is correct |
17 |
Correct |
55 ms |
13448 KB |
Output is correct |
18 |
Correct |
51 ms |
13132 KB |
Output is correct |
19 |
Correct |
52 ms |
13328 KB |
Output is correct |
20 |
Correct |
53 ms |
13320 KB |
Output is correct |
21 |
Correct |
52 ms |
13316 KB |
Output is correct |
22 |
Correct |
57 ms |
13320 KB |
Output is correct |
23 |
Correct |
46 ms |
12412 KB |
Output is correct |
24 |
Correct |
50 ms |
12240 KB |
Output is correct |
25 |
Correct |
45 ms |
12616 KB |
Output is correct |
26 |
Correct |
45 ms |
12732 KB |
Output is correct |
27 |
Correct |
52 ms |
13172 KB |
Output is correct |
28 |
Correct |
55 ms |
13140 KB |
Output is correct |
29 |
Correct |
51 ms |
13160 KB |
Output is correct |
30 |
Correct |
55 ms |
13184 KB |
Output is correct |
31 |
Correct |
48 ms |
12428 KB |
Output is correct |
32 |
Correct |
56 ms |
12372 KB |
Output is correct |
33 |
Correct |
50 ms |
12500 KB |
Output is correct |
34 |
Correct |
51 ms |
12688 KB |
Output is correct |
35 |
Correct |
53 ms |
13040 KB |
Output is correct |
36 |
Correct |
51 ms |
13060 KB |
Output is correct |
37 |
Correct |
49 ms |
13012 KB |
Output is correct |
38 |
Correct |
50 ms |
13004 KB |
Output is correct |
39 |
Correct |
49 ms |
13160 KB |
Output is correct |
40 |
Correct |
55 ms |
13012 KB |
Output is correct |
41 |
Correct |
63 ms |
13516 KB |
Output is correct |
42 |
Correct |
57 ms |
13572 KB |
Output is correct |
43 |
Correct |
55 ms |
13620 KB |
Output is correct |
44 |
Correct |
59 ms |
13232 KB |
Output is correct |
45 |
Correct |
54 ms |
13492 KB |
Output is correct |
46 |
Correct |
64 ms |
13300 KB |
Output is correct |
47 |
Correct |
56 ms |
13012 KB |
Output is correct |
48 |
Correct |
52 ms |
13244 KB |
Output is correct |
49 |
Correct |
47 ms |
13168 KB |
Output is correct |
50 |
Correct |
50 ms |
13112 KB |
Output is correct |
51 |
Correct |
45 ms |
12856 KB |
Output is correct |
52 |
Correct |
45 ms |
12628 KB |
Output is correct |
53 |
Correct |
43 ms |
12872 KB |
Output is correct |
54 |
Correct |
43 ms |
12852 KB |
Output is correct |
55 |
Correct |
44 ms |
12876 KB |
Output is correct |
56 |
Correct |
43 ms |
12832 KB |
Output is correct |
57 |
Correct |
47 ms |
12396 KB |
Output is correct |
58 |
Correct |
46 ms |
12400 KB |
Output is correct |
59 |
Correct |
46 ms |
12684 KB |
Output is correct |
60 |
Correct |
45 ms |
12672 KB |
Output is correct |