#include "Anthony.h"
#include <vector>
#include<queue>
#include<iostream>
using namespace std;
#define pi pair<int,int>
#define x first
#define y second
vector<int> sequ = { 0, 1, 0, 0, 1, 1 };
int n, m;
void dfs(int i, int col, int seq, int f, vector<vector<pi>>& g, vector<int>&res) {
if (g[i].size() == 1 && f != -1) return;
if ((g[i].size() == 2 && f != -1) || g[i].size() == 1) {
if (seq == -1) seq = (col == 0) ? 0 : 5;
(seq += 1) %= 6;
int ni = (g[i][0].x == f) ? 1 : 0;
res[g[i][ni].y] = sequ[seq];
dfs(g[i][ni].x, sequ[seq], seq, i, g, res);
return;
}
for (pi p : g[i]) {
if (p.x == f) continue;
res[p.y] = 1 - col;
dfs(p.x, 1 - col, -1, i, g, res);
}
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
n = N; m = M;
vector<vector<pi>> g(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 >= 3) {
vector<int> dist(n, 1e9);
dist[0] = 0;
queue<int> q;
q.push(0);
while (q.size()) {
int u = q.front(); q.pop();
for (pi j : g[u]) {
if (dist[j.x] > dist[u] + 1) {
dist[j.x] = dist[u] + 1;
q.push(j.x);
}
}
}
vector<int> res(m);
for (int i = 0; i < m; i++) {
res[i] = min(dist[U[i]] , dist[V[i]]) % 3;
}
return res;
}
else {
vector<int> res(m);
dfs(0, 1, -1, -1, g, res);
//for (int i = 0; i < m; i++) { cout << U[i] << ' ' << V[i] << ' ' << res[i] << endl; }
return res;
}
}
#include "Catherine.h"
#include <vector>
#include <iostream>
using namespace std;
int v = -1,a,b;
bool flag = 0;
vector<int> last;
void Init(int A, int B) {
a = A;
b = B;
v = -1;
flag = 0;
last.clear();
}
vector<int> seqi = { 0, 1, 0, 0, 1, 1 };
bool check() {
//for (int i : last) cout << i << ' '; cout << endl;
for (int i = 0; i < 6; i++) {
bool fl = 1;
for (int j = 0; j < 5; j++) {
if (last[j] != seqi[(i + j) % 6]) fl = 0;
}
if (fl) return 0;
}
return 1;
}
int Move(vector<int> y) {
if (a >= 3) {
if (v != -1) {
(v += 2) %= 3;
return v;
}
if (y[0] && !y[2]) v = 0;
if (!y[1] && y[2]) v = 2;
if (!y[0] && y[1]) v = 1;
return v;
}
else {
if (flag) {
//cout << "C" << endl;
if (y[0] && y[1]) v = 1 - v;
else if (y[0]) v = 0;
else if (y[1]) v = 1;
return v;
}
else if (v == -1) {
//cout << "A" << endl;
if (y[0] + y[1] > 2) {
if (y[0] > 1) v = 1;
else v = 0;
flag = 1;
return v;
}
if (y[0] + y[1] == 1) {
if (y[0]) v = 0;
else v = 1;
flag = 1;
return v;
}
if (y[0]) last.push_back(0);
if (y[1]) { v = 1; last.push_back(1);}
if (y[0] == 2) { v = 0; last.push_back(0); }
if (y[1] == 2) { last.push_back(1); }
return v;
}
else {
//cout << "B" << endl;
if (y[0] + y[1] > 1) {
flag = 1;
if (y[v]) {
v = 1 - v;
return v;
}
else return -1;
}
if (y[0] + y[1] == 0) {
flag = 1;
return -1;
}
if (y[0]) v = 0;
else v = 1;
last.push_back(v);
if (last.size() < 5) return v;
flag = 1;
if (check()) return v;
v = last[3];
return -1;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
15220 KB |
Output is correct |
2 |
Correct |
1 ms |
792 KB |
Output is correct |
3 |
Correct |
26 ms |
14684 KB |
Output is correct |
4 |
Correct |
37 ms |
16244 KB |
Output is correct |
5 |
Correct |
39 ms |
16196 KB |
Output is correct |
6 |
Correct |
32 ms |
15016 KB |
Output is correct |
7 |
Correct |
31 ms |
14928 KB |
Output is correct |
8 |
Correct |
36 ms |
15708 KB |
Output is correct |
9 |
Correct |
36 ms |
15732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
15220 KB |
Output is correct |
2 |
Correct |
1 ms |
792 KB |
Output is correct |
3 |
Correct |
26 ms |
14684 KB |
Output is correct |
4 |
Correct |
37 ms |
16244 KB |
Output is correct |
5 |
Correct |
39 ms |
16196 KB |
Output is correct |
6 |
Correct |
32 ms |
15016 KB |
Output is correct |
7 |
Correct |
31 ms |
14928 KB |
Output is correct |
8 |
Correct |
36 ms |
15708 KB |
Output is correct |
9 |
Correct |
36 ms |
15732 KB |
Output is correct |
10 |
Correct |
27 ms |
13184 KB |
Output is correct |
11 |
Correct |
27 ms |
13180 KB |
Output is correct |
12 |
Correct |
30 ms |
13168 KB |
Output is correct |
13 |
Correct |
27 ms |
13140 KB |
Output is correct |
14 |
Correct |
33 ms |
13104 KB |
Output is correct |
15 |
Correct |
34 ms |
13648 KB |
Output is correct |
16 |
Correct |
38 ms |
15736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
12712 KB |
Output is correct |
2 |
Correct |
0 ms |
792 KB |
Output is correct |
3 |
Correct |
28 ms |
12812 KB |
Output is correct |
4 |
Correct |
53 ms |
14108 KB |
Output is correct |
5 |
Correct |
35 ms |
14124 KB |
Output is correct |
6 |
Correct |
26 ms |
12660 KB |
Output is correct |
7 |
Correct |
28 ms |
12696 KB |
Output is correct |
8 |
Correct |
39 ms |
13412 KB |
Output is correct |
9 |
Correct |
35 ms |
13436 KB |
Output is correct |
10 |
Correct |
32 ms |
13228 KB |
Output is correct |
11 |
Correct |
32 ms |
13008 KB |
Output is correct |
12 |
Correct |
37 ms |
13244 KB |
Output is correct |
13 |
Correct |
38 ms |
13132 KB |
Output is correct |
14 |
Correct |
44 ms |
13344 KB |
Output is correct |
15 |
Correct |
39 ms |
13516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
12712 KB |
Output is correct |
2 |
Correct |
0 ms |
792 KB |
Output is correct |
3 |
Correct |
28 ms |
12812 KB |
Output is correct |
4 |
Correct |
53 ms |
14108 KB |
Output is correct |
5 |
Correct |
35 ms |
14124 KB |
Output is correct |
6 |
Correct |
26 ms |
12660 KB |
Output is correct |
7 |
Correct |
28 ms |
12696 KB |
Output is correct |
8 |
Correct |
39 ms |
13412 KB |
Output is correct |
9 |
Correct |
35 ms |
13436 KB |
Output is correct |
10 |
Correct |
32 ms |
13228 KB |
Output is correct |
11 |
Correct |
32 ms |
13008 KB |
Output is correct |
12 |
Correct |
37 ms |
13244 KB |
Output is correct |
13 |
Correct |
38 ms |
13132 KB |
Output is correct |
14 |
Correct |
44 ms |
13344 KB |
Output is correct |
15 |
Correct |
39 ms |
13516 KB |
Output is correct |
16 |
Correct |
27 ms |
11260 KB |
Output is correct |
17 |
Correct |
33 ms |
11224 KB |
Output is correct |
18 |
Correct |
31 ms |
11200 KB |
Output is correct |
19 |
Correct |
33 ms |
11120 KB |
Output is correct |
20 |
Correct |
38 ms |
11652 KB |
Output is correct |
21 |
Correct |
33 ms |
11704 KB |
Output is correct |
22 |
Correct |
39 ms |
13676 KB |
Output is correct |
23 |
Correct |
30 ms |
11384 KB |
Output is correct |
24 |
Correct |
35 ms |
11416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1044 KB |
Output is correct |
2 |
Correct |
1 ms |
1032 KB |
Output is correct |
3 |
Correct |
2 ms |
1044 KB |
Output is correct |
4 |
Correct |
2 ms |
1052 KB |
Output is correct |
5 |
Correct |
2 ms |
1044 KB |
Output is correct |
6 |
Correct |
2 ms |
1044 KB |
Output is correct |
7 |
Correct |
2 ms |
1044 KB |
Output is correct |
8 |
Correct |
2 ms |
1052 KB |
Output is correct |
9 |
Correct |
2 ms |
1076 KB |
Output is correct |
10 |
Correct |
2 ms |
1072 KB |
Output is correct |
11 |
Correct |
2 ms |
1068 KB |
Output is correct |
12 |
Correct |
2 ms |
1068 KB |
Output is correct |
13 |
Correct |
2 ms |
1076 KB |
Output is correct |
14 |
Correct |
2 ms |
1068 KB |
Output is correct |
15 |
Correct |
2 ms |
1072 KB |
Output is correct |
16 |
Correct |
2 ms |
1060 KB |
Output is correct |
17 |
Correct |
2 ms |
1076 KB |
Output is correct |
18 |
Correct |
2 ms |
1128 KB |
Output is correct |
19 |
Correct |
2 ms |
1068 KB |
Output is correct |
20 |
Correct |
2 ms |
916 KB |
Output is correct |
21 |
Correct |
2 ms |
1068 KB |
Output is correct |
22 |
Correct |
2 ms |
1068 KB |
Output is correct |
23 |
Correct |
2 ms |
1040 KB |
Output is correct |
24 |
Correct |
2 ms |
1292 KB |
Output is correct |
25 |
Correct |
2 ms |
1044 KB |
Output is correct |
26 |
Correct |
2 ms |
1036 KB |
Output is correct |
27 |
Correct |
2 ms |
1052 KB |
Output is correct |
28 |
Correct |
2 ms |
1044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
10824 KB |
Output is correct |
2 |
Correct |
33 ms |
11592 KB |
Output is correct |
3 |
Correct |
1 ms |
792 KB |
Output is correct |
4 |
Correct |
22 ms |
10624 KB |
Output is correct |
5 |
Correct |
32 ms |
12164 KB |
Output is correct |
6 |
Correct |
35 ms |
12084 KB |
Output is correct |
7 |
Correct |
27 ms |
11460 KB |
Output is correct |
8 |
Correct |
27 ms |
11068 KB |
Output is correct |
9 |
Correct |
41 ms |
12152 KB |
Output is correct |
10 |
Correct |
36 ms |
12132 KB |
Output is correct |
11 |
Correct |
35 ms |
12152 KB |
Output is correct |
12 |
Correct |
32 ms |
12100 KB |
Output is correct |
13 |
Correct |
36 ms |
12096 KB |
Output is correct |
14 |
Correct |
34 ms |
12164 KB |
Output is correct |
15 |
Correct |
38 ms |
12172 KB |
Output is correct |
16 |
Correct |
35 ms |
12068 KB |
Output is correct |
17 |
Correct |
31 ms |
11908 KB |
Output is correct |
18 |
Correct |
31 ms |
11828 KB |
Output is correct |
19 |
Correct |
39 ms |
11808 KB |
Output is correct |
20 |
Correct |
31 ms |
11828 KB |
Output is correct |
21 |
Correct |
31 ms |
12116 KB |
Output is correct |
22 |
Correct |
31 ms |
11896 KB |
Output is correct |
23 |
Correct |
27 ms |
10896 KB |
Output is correct |
24 |
Correct |
32 ms |
10908 KB |
Output is correct |
25 |
Correct |
26 ms |
11180 KB |
Output is correct |
26 |
Correct |
30 ms |
11224 KB |
Output is correct |
27 |
Correct |
33 ms |
11912 KB |
Output is correct |
28 |
Correct |
31 ms |
11944 KB |
Output is correct |
29 |
Correct |
31 ms |
11948 KB |
Output is correct |
30 |
Correct |
30 ms |
11916 KB |
Output is correct |
31 |
Correct |
34 ms |
10828 KB |
Output is correct |
32 |
Correct |
30 ms |
10856 KB |
Output is correct |
33 |
Correct |
26 ms |
11180 KB |
Output is correct |
34 |
Correct |
27 ms |
11100 KB |
Output is correct |
35 |
Correct |
30 ms |
11668 KB |
Output is correct |
36 |
Correct |
33 ms |
11696 KB |
Output is correct |
37 |
Correct |
30 ms |
11680 KB |
Output is correct |
38 |
Correct |
30 ms |
11608 KB |
Output is correct |
39 |
Correct |
28 ms |
11672 KB |
Output is correct |
40 |
Correct |
30 ms |
11600 KB |
Output is correct |
41 |
Correct |
31 ms |
11884 KB |
Output is correct |
42 |
Correct |
31 ms |
11888 KB |
Output is correct |
43 |
Correct |
32 ms |
11912 KB |
Output is correct |
44 |
Correct |
33 ms |
12176 KB |
Output is correct |
45 |
Correct |
30 ms |
11896 KB |
Output is correct |
46 |
Correct |
31 ms |
12156 KB |
Output is correct |
47 |
Correct |
28 ms |
11652 KB |
Output is correct |
48 |
Correct |
28 ms |
11648 KB |
Output is correct |
49 |
Correct |
28 ms |
11396 KB |
Output is correct |
50 |
Correct |
28 ms |
11600 KB |
Output is correct |
51 |
Correct |
29 ms |
11132 KB |
Output is correct |
52 |
Correct |
28 ms |
11084 KB |
Output is correct |
53 |
Correct |
27 ms |
11636 KB |
Output is correct |
54 |
Correct |
26 ms |
11148 KB |
Output is correct |
55 |
Correct |
26 ms |
11144 KB |
Output is correct |
56 |
Correct |
27 ms |
11132 KB |
Output is correct |
57 |
Correct |
32 ms |
11672 KB |
Output is correct |
58 |
Correct |
27 ms |
11400 KB |
Output is correct |
59 |
Correct |
27 ms |
11128 KB |
Output is correct |
60 |
Correct |
27 ms |
11128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
10916 KB |
Output is correct |
2 |
Correct |
30 ms |
11688 KB |
Output is correct |
3 |
Correct |
2 ms |
788 KB |
Output is correct |
4 |
Correct |
23 ms |
10568 KB |
Output is correct |
5 |
Correct |
32 ms |
12160 KB |
Output is correct |
6 |
Correct |
41 ms |
12168 KB |
Output is correct |
7 |
Correct |
28 ms |
11140 KB |
Output is correct |
8 |
Correct |
30 ms |
11132 KB |
Output is correct |
9 |
Correct |
37 ms |
12168 KB |
Output is correct |
10 |
Correct |
32 ms |
12132 KB |
Output is correct |
11 |
Correct |
31 ms |
11996 KB |
Output is correct |
12 |
Correct |
33 ms |
12084 KB |
Output is correct |
13 |
Correct |
33 ms |
12024 KB |
Output is correct |
14 |
Correct |
36 ms |
12236 KB |
Output is correct |
15 |
Correct |
32 ms |
12156 KB |
Output is correct |
16 |
Correct |
35 ms |
12600 KB |
Output is correct |
17 |
Correct |
28 ms |
11644 KB |
Output is correct |
18 |
Correct |
32 ms |
11696 KB |
Output is correct |
19 |
Correct |
36 ms |
11828 KB |
Output is correct |
20 |
Correct |
30 ms |
11732 KB |
Output is correct |
21 |
Correct |
31 ms |
11908 KB |
Output is correct |
22 |
Correct |
34 ms |
11908 KB |
Output is correct |
23 |
Correct |
27 ms |
10876 KB |
Output is correct |
24 |
Correct |
27 ms |
10932 KB |
Output is correct |
25 |
Correct |
26 ms |
11120 KB |
Output is correct |
26 |
Correct |
26 ms |
11264 KB |
Output is correct |
27 |
Correct |
35 ms |
11928 KB |
Output is correct |
28 |
Correct |
30 ms |
11944 KB |
Output is correct |
29 |
Correct |
39 ms |
11924 KB |
Output is correct |
30 |
Correct |
28 ms |
11936 KB |
Output is correct |
31 |
Correct |
28 ms |
10928 KB |
Output is correct |
32 |
Correct |
26 ms |
10916 KB |
Output is correct |
33 |
Correct |
26 ms |
11124 KB |
Output is correct |
34 |
Correct |
26 ms |
11424 KB |
Output is correct |
35 |
Correct |
31 ms |
11632 KB |
Output is correct |
36 |
Correct |
28 ms |
11676 KB |
Output is correct |
37 |
Correct |
30 ms |
11608 KB |
Output is correct |
38 |
Correct |
34 ms |
11612 KB |
Output is correct |
39 |
Correct |
28 ms |
11696 KB |
Output is correct |
40 |
Correct |
34 ms |
11688 KB |
Output is correct |
41 |
Correct |
36 ms |
11856 KB |
Output is correct |
42 |
Correct |
36 ms |
11904 KB |
Output is correct |
43 |
Correct |
36 ms |
12012 KB |
Output is correct |
44 |
Correct |
35 ms |
12148 KB |
Output is correct |
45 |
Correct |
38 ms |
11896 KB |
Output is correct |
46 |
Correct |
36 ms |
12156 KB |
Output is correct |
47 |
Correct |
30 ms |
11728 KB |
Output is correct |
48 |
Correct |
28 ms |
11840 KB |
Output is correct |
49 |
Correct |
27 ms |
11632 KB |
Output is correct |
50 |
Correct |
28 ms |
11644 KB |
Output is correct |
51 |
Correct |
26 ms |
11120 KB |
Output is correct |
52 |
Correct |
27 ms |
11120 KB |
Output is correct |
53 |
Correct |
28 ms |
11644 KB |
Output is correct |
54 |
Correct |
27 ms |
11128 KB |
Output is correct |
55 |
Correct |
30 ms |
11044 KB |
Output is correct |
56 |
Correct |
26 ms |
11132 KB |
Output is correct |
57 |
Correct |
26 ms |
11384 KB |
Output is correct |
58 |
Correct |
28 ms |
11408 KB |
Output is correct |
59 |
Correct |
27 ms |
11140 KB |
Output is correct |
60 |
Correct |
27 ms |
11092 KB |
Output is correct |