// .. And I love you, it's ruining my life
#include "Anthony.h"
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;
namespace
{
const int d[6] = { 0, 0, 1, 0, 1, 1 };
vector<vector<pair<int, int> > > g;
vector<int> col;
void dfs2(int u, int p = -1, int c = 1, int i = -1)
{
if (!u || g[u].size() != 2)
{
for (pair<int, int> v : g[u]) if (v.first != p)
{
col[v.second] = c ^ 1;
dfs2(v.first, u, (c ^ 1));
}
}
else
{
if (i == -1) i = (c ? 2 : 0);
for (pair<int, int> v : g[u]) if (v.first != p)
{
col[v.second] = d[(i + 1) % 6];
dfs2(v.first, u, d[(i + 1) % 6], (i + 1) % 6);
}
}
}
void bfs3()
{
vector<int> d(g.size(), -1);
d[0] = 0;
queue<int> q;
q.push(0);
while (!q.empty())
{
int u = q.front();
q.pop();
for (pair<int, int> v : g[u])
{
if (d[v.first] == -1)
{
q.push(v.first);
d[v.first] = d[u] + 1;
}
col[v.second] = min(d[v.first], d[u]) % 3;
}
}
}
}
vector<int> Mark(int n, int m, int a, int b, vector<int> u, vector<int> v)
{
col.assign(m, -1), g.assign(n, {});
for (int i = 0; i < m; i++) g[u[i]].push_back({ v[i], i }), g[v[i]].push_back({ u[i], i });
if (a == 2)
{
::dfs2(0);
return col;
}
else
{
::bfs3();
return col;
}
}
// All my mornings are Mondays stuck in an endless February...
// I took the miracle move-on drug, the effects were temporary
#include "Catherine.h"
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;
namespace
{
const int d[6] = { 0, 0, 1, 0, 1, 1 };
int a, b, lst, go;
vector<int> v;
int cnt(bool rev = false)
{
int ans = 0;
vector<int> v2 = v;
if (rev) reverse(v2.begin(), v2.end());
for (int i = 0; i < 6; i++)
{
bool ok = true;
for (int j = 0; j < v2.size(); j++) if (d[(i + j) % 6] != v2[j])
{
ok = false;
break;
}
if (ok) ans++;
}
return ans;
}
}
void Init(int A, int B)
{
::a = A;
::b = B;
lst = -1, go = 0;
v.clear();
}
int Move(vector<int> y)
{
if (a == 2)
{
int sum = y[0] + y[1] + (lst != -1);
if (sum != 2)
{
go = 1;
if (lst != -1) y[lst]++;
int x = (y[0] == 1 ? 0 : 1);
if (lst == x) return lst = x, -1;
return lst = x;
}
if (go == 1)
{
return lst = (y[0] == 1 ? 0 : 1);
}
for (int i = 0; i < y.size(); i++) for (int j = 0; j < y[i]; j++) v.push_back(i);
int fw = cnt(false), bk = cnt(true);
if (bk == 0) // ideme sa otocit
{
go = 1;
return -1;
}
if (fw == 0) // navzdy budem pokracovat v tomto smere
{
go = 1;
int x = (y[0] == 1 ? 0 : 1);
return lst = x;
}
if (lst == -1) // prvy vrchol
{
if (v.back() != 1) reverse(v.begin(), v.end());
return lst = v[1];
}
return lst = (y[0] == 1 ? 0 : 1);
}
else
{
if (lst != -1) y[lst]++;
if (!y[0] && !y[1]) return lst = 2;
if (!y[0] && !y[2]) return lst = 1;
if (!y[1] && !y[2]) return lst = 0;
if (!y[0]) return lst = 1;
if (!y[1]) return lst = 2;
if (!y[2]) return lst = 0;
}
}
Compilation message
Catherine.cpp: In function 'int {anonymous}::cnt(bool)':
Catherine.cpp:36:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for (int j = 0; j < v2.size(); j++) if (d[(i + j) % 6] != v2[j])
| ~~^~~~~~~~~~~
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:72:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for (int i = 0; i < y.size(); i++) for (int j = 0; j < y[i]; j++) v.push_back(i);
| ~~^~~~~~~~~~
Catherine.cpp:102:1: warning: control reaches end of non-void function [-Wreturn-type]
102 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
15740 KB |
Output is correct |
2 |
Correct |
1 ms |
776 KB |
Output is correct |
3 |
Correct |
22 ms |
15428 KB |
Output is correct |
4 |
Correct |
32 ms |
16880 KB |
Output is correct |
5 |
Correct |
32 ms |
16996 KB |
Output is correct |
6 |
Correct |
26 ms |
15752 KB |
Output is correct |
7 |
Correct |
27 ms |
15876 KB |
Output is correct |
8 |
Correct |
29 ms |
16440 KB |
Output is correct |
9 |
Correct |
31 ms |
16744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
15740 KB |
Output is correct |
2 |
Correct |
1 ms |
776 KB |
Output is correct |
3 |
Correct |
22 ms |
15428 KB |
Output is correct |
4 |
Correct |
32 ms |
16880 KB |
Output is correct |
5 |
Correct |
32 ms |
16996 KB |
Output is correct |
6 |
Correct |
26 ms |
15752 KB |
Output is correct |
7 |
Correct |
27 ms |
15876 KB |
Output is correct |
8 |
Correct |
29 ms |
16440 KB |
Output is correct |
9 |
Correct |
31 ms |
16744 KB |
Output is correct |
10 |
Correct |
27 ms |
14084 KB |
Output is correct |
11 |
Correct |
23 ms |
13904 KB |
Output is correct |
12 |
Correct |
26 ms |
13716 KB |
Output is correct |
13 |
Correct |
30 ms |
13904 KB |
Output is correct |
14 |
Correct |
27 ms |
14120 KB |
Output is correct |
15 |
Correct |
32 ms |
14412 KB |
Output is correct |
16 |
Correct |
31 ms |
16588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
13184 KB |
Output is correct |
2 |
Correct |
0 ms |
792 KB |
Output is correct |
3 |
Correct |
22 ms |
13172 KB |
Output is correct |
4 |
Correct |
37 ms |
14896 KB |
Output is correct |
5 |
Correct |
32 ms |
14756 KB |
Output is correct |
6 |
Correct |
26 ms |
13652 KB |
Output is correct |
7 |
Correct |
26 ms |
13636 KB |
Output is correct |
8 |
Correct |
32 ms |
14416 KB |
Output is correct |
9 |
Correct |
27 ms |
14428 KB |
Output is correct |
10 |
Correct |
26 ms |
14116 KB |
Output is correct |
11 |
Correct |
26 ms |
14172 KB |
Output is correct |
12 |
Correct |
30 ms |
13820 KB |
Output is correct |
13 |
Correct |
27 ms |
14184 KB |
Output is correct |
14 |
Correct |
27 ms |
14432 KB |
Output is correct |
15 |
Correct |
34 ms |
14060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
13184 KB |
Output is correct |
2 |
Correct |
0 ms |
792 KB |
Output is correct |
3 |
Correct |
22 ms |
13172 KB |
Output is correct |
4 |
Correct |
37 ms |
14896 KB |
Output is correct |
5 |
Correct |
32 ms |
14756 KB |
Output is correct |
6 |
Correct |
26 ms |
13652 KB |
Output is correct |
7 |
Correct |
26 ms |
13636 KB |
Output is correct |
8 |
Correct |
32 ms |
14416 KB |
Output is correct |
9 |
Correct |
27 ms |
14428 KB |
Output is correct |
10 |
Correct |
26 ms |
14116 KB |
Output is correct |
11 |
Correct |
26 ms |
14172 KB |
Output is correct |
12 |
Correct |
30 ms |
13820 KB |
Output is correct |
13 |
Correct |
27 ms |
14184 KB |
Output is correct |
14 |
Correct |
27 ms |
14432 KB |
Output is correct |
15 |
Correct |
34 ms |
14060 KB |
Output is correct |
16 |
Correct |
25 ms |
12244 KB |
Output is correct |
17 |
Correct |
31 ms |
11980 KB |
Output is correct |
18 |
Correct |
29 ms |
11980 KB |
Output is correct |
19 |
Correct |
23 ms |
11860 KB |
Output is correct |
20 |
Correct |
25 ms |
12464 KB |
Output is correct |
21 |
Correct |
30 ms |
12360 KB |
Output is correct |
22 |
Correct |
31 ms |
14388 KB |
Output is correct |
23 |
Correct |
24 ms |
12208 KB |
Output is correct |
24 |
Correct |
23 ms |
12120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1052 KB |
Output is correct |
2 |
Correct |
0 ms |
792 KB |
Output is correct |
3 |
Correct |
0 ms |
1052 KB |
Output is correct |
4 |
Correct |
2 ms |
1036 KB |
Output is correct |
5 |
Correct |
2 ms |
1048 KB |
Output is correct |
6 |
Correct |
2 ms |
1304 KB |
Output is correct |
7 |
Correct |
0 ms |
1048 KB |
Output is correct |
8 |
Correct |
2 ms |
1048 KB |
Output is correct |
9 |
Correct |
0 ms |
1044 KB |
Output is correct |
10 |
Correct |
1 ms |
1044 KB |
Output is correct |
11 |
Correct |
0 ms |
1052 KB |
Output is correct |
12 |
Correct |
1 ms |
1052 KB |
Output is correct |
13 |
Correct |
0 ms |
1044 KB |
Output is correct |
14 |
Correct |
2 ms |
1044 KB |
Output is correct |
15 |
Correct |
1 ms |
1052 KB |
Output is correct |
16 |
Correct |
2 ms |
1048 KB |
Output is correct |
17 |
Correct |
1 ms |
1052 KB |
Output is correct |
18 |
Correct |
0 ms |
1052 KB |
Output is correct |
19 |
Correct |
1 ms |
1036 KB |
Output is correct |
20 |
Correct |
2 ms |
1044 KB |
Output is correct |
21 |
Correct |
2 ms |
1044 KB |
Output is correct |
22 |
Correct |
2 ms |
1056 KB |
Output is correct |
23 |
Correct |
1 ms |
1052 KB |
Output is correct |
24 |
Correct |
0 ms |
1052 KB |
Output is correct |
25 |
Correct |
2 ms |
1052 KB |
Output is correct |
26 |
Correct |
2 ms |
1052 KB |
Output is correct |
27 |
Correct |
0 ms |
1052 KB |
Output is correct |
28 |
Correct |
0 ms |
1056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
11388 KB |
Output is correct |
2 |
Correct |
27 ms |
12412 KB |
Output is correct |
3 |
Correct |
0 ms |
792 KB |
Output is correct |
4 |
Correct |
22 ms |
11208 KB |
Output is correct |
5 |
Correct |
27 ms |
13788 KB |
Output is correct |
6 |
Correct |
34 ms |
13696 KB |
Output is correct |
7 |
Correct |
30 ms |
12884 KB |
Output is correct |
8 |
Correct |
25 ms |
12668 KB |
Output is correct |
9 |
Correct |
28 ms |
13676 KB |
Output is correct |
10 |
Correct |
27 ms |
13700 KB |
Output is correct |
11 |
Correct |
28 ms |
13604 KB |
Output is correct |
12 |
Correct |
30 ms |
13704 KB |
Output is correct |
13 |
Correct |
34 ms |
13784 KB |
Output is correct |
14 |
Correct |
34 ms |
13684 KB |
Output is correct |
15 |
Correct |
34 ms |
13624 KB |
Output is correct |
16 |
Correct |
35 ms |
13760 KB |
Output is correct |
17 |
Correct |
26 ms |
13436 KB |
Output is correct |
18 |
Correct |
32 ms |
13436 KB |
Output is correct |
19 |
Correct |
26 ms |
13440 KB |
Output is correct |
20 |
Correct |
32 ms |
13444 KB |
Output is correct |
21 |
Correct |
27 ms |
13448 KB |
Output is correct |
22 |
Correct |
27 ms |
13468 KB |
Output is correct |
23 |
Correct |
26 ms |
11384 KB |
Output is correct |
24 |
Correct |
27 ms |
11404 KB |
Output is correct |
25 |
Correct |
23 ms |
11656 KB |
Output is correct |
26 |
Correct |
26 ms |
11880 KB |
Output is correct |
27 |
Correct |
26 ms |
12412 KB |
Output is correct |
28 |
Correct |
28 ms |
12428 KB |
Output is correct |
29 |
Correct |
26 ms |
12412 KB |
Output is correct |
30 |
Correct |
32 ms |
12416 KB |
Output is correct |
31 |
Correct |
22 ms |
11396 KB |
Output is correct |
32 |
Correct |
22 ms |
11400 KB |
Output is correct |
33 |
Correct |
23 ms |
11648 KB |
Output is correct |
34 |
Correct |
26 ms |
11640 KB |
Output is correct |
35 |
Correct |
28 ms |
12488 KB |
Output is correct |
36 |
Correct |
34 ms |
12420 KB |
Output is correct |
37 |
Correct |
26 ms |
12428 KB |
Output is correct |
38 |
Correct |
28 ms |
12380 KB |
Output is correct |
39 |
Correct |
26 ms |
12428 KB |
Output is correct |
40 |
Correct |
26 ms |
12404 KB |
Output is correct |
41 |
Correct |
26 ms |
12984 KB |
Output is correct |
42 |
Correct |
32 ms |
12968 KB |
Output is correct |
43 |
Correct |
38 ms |
12876 KB |
Output is correct |
44 |
Correct |
31 ms |
12844 KB |
Output is correct |
45 |
Correct |
26 ms |
12996 KB |
Output is correct |
46 |
Correct |
26 ms |
12940 KB |
Output is correct |
47 |
Correct |
28 ms |
12304 KB |
Output is correct |
48 |
Correct |
26 ms |
12376 KB |
Output is correct |
49 |
Correct |
27 ms |
12332 KB |
Output is correct |
50 |
Correct |
24 ms |
12424 KB |
Output is correct |
51 |
Correct |
33 ms |
11572 KB |
Output is correct |
52 |
Correct |
26 ms |
11712 KB |
Output is correct |
53 |
Correct |
25 ms |
11648 KB |
Output is correct |
54 |
Correct |
24 ms |
11652 KB |
Output is correct |
55 |
Correct |
22 ms |
11660 KB |
Output is correct |
56 |
Correct |
28 ms |
11640 KB |
Output is correct |
57 |
Correct |
23 ms |
11648 KB |
Output is correct |
58 |
Correct |
22 ms |
11660 KB |
Output is correct |
59 |
Correct |
26 ms |
11380 KB |
Output is correct |
60 |
Correct |
22 ms |
11388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
11264 KB |
Output is correct |
2 |
Correct |
26 ms |
12196 KB |
Output is correct |
3 |
Correct |
0 ms |
780 KB |
Output is correct |
4 |
Correct |
19 ms |
11056 KB |
Output is correct |
5 |
Correct |
31 ms |
13604 KB |
Output is correct |
6 |
Correct |
33 ms |
13716 KB |
Output is correct |
7 |
Correct |
25 ms |
12680 KB |
Output is correct |
8 |
Correct |
25 ms |
12680 KB |
Output is correct |
9 |
Correct |
33 ms |
13684 KB |
Output is correct |
10 |
Correct |
34 ms |
13680 KB |
Output is correct |
11 |
Correct |
30 ms |
13788 KB |
Output is correct |
12 |
Correct |
34 ms |
13620 KB |
Output is correct |
13 |
Correct |
33 ms |
13700 KB |
Output is correct |
14 |
Correct |
34 ms |
13864 KB |
Output is correct |
15 |
Correct |
28 ms |
13704 KB |
Output is correct |
16 |
Correct |
28 ms |
13692 KB |
Output is correct |
17 |
Correct |
30 ms |
13440 KB |
Output is correct |
18 |
Correct |
31 ms |
13444 KB |
Output is correct |
19 |
Correct |
33 ms |
13336 KB |
Output is correct |
20 |
Correct |
26 ms |
13348 KB |
Output is correct |
21 |
Correct |
30 ms |
13364 KB |
Output is correct |
22 |
Correct |
27 ms |
13436 KB |
Output is correct |
23 |
Correct |
26 ms |
11352 KB |
Output is correct |
24 |
Correct |
22 ms |
11404 KB |
Output is correct |
25 |
Correct |
27 ms |
11648 KB |
Output is correct |
26 |
Correct |
22 ms |
11904 KB |
Output is correct |
27 |
Correct |
26 ms |
12424 KB |
Output is correct |
28 |
Correct |
30 ms |
12352 KB |
Output is correct |
29 |
Correct |
25 ms |
12340 KB |
Output is correct |
30 |
Correct |
24 ms |
12432 KB |
Output is correct |
31 |
Correct |
23 ms |
11400 KB |
Output is correct |
32 |
Correct |
27 ms |
11396 KB |
Output is correct |
33 |
Correct |
23 ms |
11904 KB |
Output is correct |
34 |
Correct |
27 ms |
11880 KB |
Output is correct |
35 |
Correct |
30 ms |
12408 KB |
Output is correct |
36 |
Correct |
26 ms |
12416 KB |
Output is correct |
37 |
Correct |
26 ms |
12340 KB |
Output is correct |
38 |
Correct |
27 ms |
12456 KB |
Output is correct |
39 |
Correct |
24 ms |
12404 KB |
Output is correct |
40 |
Correct |
32 ms |
12416 KB |
Output is correct |
41 |
Correct |
31 ms |
12924 KB |
Output is correct |
42 |
Correct |
27 ms |
12940 KB |
Output is correct |
43 |
Correct |
29 ms |
12896 KB |
Output is correct |
44 |
Correct |
30 ms |
12924 KB |
Output is correct |
45 |
Correct |
27 ms |
12852 KB |
Output is correct |
46 |
Correct |
26 ms |
12924 KB |
Output is correct |
47 |
Correct |
25 ms |
12196 KB |
Output is correct |
48 |
Correct |
27 ms |
12404 KB |
Output is correct |
49 |
Correct |
25 ms |
12164 KB |
Output is correct |
50 |
Correct |
29 ms |
12392 KB |
Output is correct |
51 |
Correct |
23 ms |
11636 KB |
Output is correct |
52 |
Correct |
22 ms |
11656 KB |
Output is correct |
53 |
Correct |
22 ms |
11652 KB |
Output is correct |
54 |
Correct |
24 ms |
12156 KB |
Output is correct |
55 |
Correct |
27 ms |
11616 KB |
Output is correct |
56 |
Correct |
22 ms |
11652 KB |
Output is correct |
57 |
Correct |
28 ms |
11628 KB |
Output is correct |
58 |
Correct |
25 ms |
11608 KB |
Output is correct |
59 |
Correct |
25 ms |
11340 KB |
Output is correct |
60 |
Correct |
23 ms |
11396 KB |
Output is correct |