#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;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
15276 KB |
Output is correct |
2 |
Correct |
1 ms |
788 KB |
Output is correct |
3 |
Correct |
26 ms |
14720 KB |
Output is correct |
4 |
Correct |
40 ms |
16248 KB |
Output is correct |
5 |
Correct |
40 ms |
16248 KB |
Output is correct |
6 |
Correct |
32 ms |
14968 KB |
Output is correct |
7 |
Correct |
31 ms |
14900 KB |
Output is correct |
8 |
Correct |
39 ms |
15704 KB |
Output is correct |
9 |
Correct |
37 ms |
15780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
15276 KB |
Output is correct |
2 |
Correct |
1 ms |
788 KB |
Output is correct |
3 |
Correct |
26 ms |
14720 KB |
Output is correct |
4 |
Correct |
40 ms |
16248 KB |
Output is correct |
5 |
Correct |
40 ms |
16248 KB |
Output is correct |
6 |
Correct |
32 ms |
14968 KB |
Output is correct |
7 |
Correct |
31 ms |
14900 KB |
Output is correct |
8 |
Correct |
39 ms |
15704 KB |
Output is correct |
9 |
Correct |
37 ms |
15780 KB |
Output is correct |
10 |
Correct |
27 ms |
13156 KB |
Output is correct |
11 |
Correct |
30 ms |
13160 KB |
Output is correct |
12 |
Correct |
28 ms |
13188 KB |
Output is correct |
13 |
Correct |
26 ms |
12848 KB |
Output is correct |
14 |
Correct |
31 ms |
13420 KB |
Output is correct |
15 |
Correct |
42 ms |
13648 KB |
Output is correct |
16 |
Correct |
40 ms |
15692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
12668 KB |
Output is correct |
2 |
Correct |
1 ms |
792 KB |
Output is correct |
3 |
Correct |
26 ms |
12408 KB |
Output is correct |
4 |
Correct |
36 ms |
14200 KB |
Output is correct |
5 |
Correct |
44 ms |
14168 KB |
Output is correct |
6 |
Correct |
30 ms |
12708 KB |
Output is correct |
7 |
Correct |
30 ms |
12708 KB |
Output is correct |
8 |
Correct |
32 ms |
13476 KB |
Output is correct |
9 |
Correct |
36 ms |
13428 KB |
Output is correct |
10 |
Correct |
36 ms |
13164 KB |
Output is correct |
11 |
Correct |
30 ms |
13224 KB |
Output is correct |
12 |
Correct |
30 ms |
13228 KB |
Output is correct |
13 |
Correct |
32 ms |
13228 KB |
Output is correct |
14 |
Correct |
37 ms |
13540 KB |
Output is correct |
15 |
Correct |
41 ms |
13408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
12668 KB |
Output is correct |
2 |
Correct |
1 ms |
792 KB |
Output is correct |
3 |
Correct |
26 ms |
12408 KB |
Output is correct |
4 |
Correct |
36 ms |
14200 KB |
Output is correct |
5 |
Correct |
44 ms |
14168 KB |
Output is correct |
6 |
Correct |
30 ms |
12708 KB |
Output is correct |
7 |
Correct |
30 ms |
12708 KB |
Output is correct |
8 |
Correct |
32 ms |
13476 KB |
Output is correct |
9 |
Correct |
36 ms |
13428 KB |
Output is correct |
10 |
Correct |
36 ms |
13164 KB |
Output is correct |
11 |
Correct |
30 ms |
13224 KB |
Output is correct |
12 |
Correct |
30 ms |
13228 KB |
Output is correct |
13 |
Correct |
32 ms |
13228 KB |
Output is correct |
14 |
Correct |
37 ms |
13540 KB |
Output is correct |
15 |
Correct |
41 ms |
13408 KB |
Output is correct |
16 |
Correct |
25 ms |
11176 KB |
Output is correct |
17 |
Correct |
25 ms |
11424 KB |
Output is correct |
18 |
Correct |
26 ms |
11084 KB |
Output is correct |
19 |
Correct |
28 ms |
11384 KB |
Output is correct |
20 |
Correct |
31 ms |
11820 KB |
Output is correct |
21 |
Correct |
27 ms |
11640 KB |
Output is correct |
22 |
Correct |
33 ms |
13696 KB |
Output is correct |
23 |
Correct |
27 ms |
11296 KB |
Output is correct |
24 |
Correct |
28 ms |
11388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1056 KB |
Output is correct |
2 |
Correct |
1 ms |
1044 KB |
Output is correct |
3 |
Correct |
2 ms |
1036 KB |
Output is correct |
4 |
Correct |
2 ms |
1052 KB |
Output is correct |
5 |
Correct |
2 ms |
1040 KB |
Output is correct |
6 |
Correct |
2 ms |
1052 KB |
Output is correct |
7 |
Correct |
2 ms |
1044 KB |
Output is correct |
8 |
Correct |
2 ms |
1040 KB |
Output is correct |
9 |
Correct |
2 ms |
1044 KB |
Output is correct |
10 |
Correct |
2 ms |
1044 KB |
Output is correct |
11 |
Correct |
2 ms |
1052 KB |
Output is correct |
12 |
Correct |
2 ms |
1036 KB |
Output is correct |
13 |
Correct |
2 ms |
1036 KB |
Output is correct |
14 |
Correct |
2 ms |
1044 KB |
Output is correct |
15 |
Correct |
2 ms |
1040 KB |
Output is correct |
16 |
Correct |
2 ms |
1036 KB |
Output is correct |
17 |
Correct |
2 ms |
1048 KB |
Output is correct |
18 |
Correct |
2 ms |
1052 KB |
Output is correct |
19 |
Correct |
2 ms |
1036 KB |
Output is correct |
20 |
Correct |
2 ms |
1052 KB |
Output is correct |
21 |
Correct |
2 ms |
1040 KB |
Output is correct |
22 |
Correct |
2 ms |
1044 KB |
Output is correct |
23 |
Correct |
2 ms |
1044 KB |
Output is correct |
24 |
Correct |
2 ms |
1044 KB |
Output is correct |
25 |
Correct |
2 ms |
1044 KB |
Output is correct |
26 |
Correct |
2 ms |
1044 KB |
Output is correct |
27 |
Correct |
2 ms |
1052 KB |
Output is correct |
28 |
Correct |
2 ms |
1052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
10900 KB |
Output is correct |
2 |
Correct |
31 ms |
11624 KB |
Output is correct |
3 |
Correct |
1 ms |
792 KB |
Output is correct |
4 |
Correct |
25 ms |
10624 KB |
Output is correct |
5 |
Correct |
36 ms |
11932 KB |
Output is correct |
6 |
Correct |
40 ms |
11912 KB |
Output is correct |
7 |
Correct |
31 ms |
11136 KB |
Output is correct |
8 |
Correct |
28 ms |
11208 KB |
Output is correct |
9 |
Correct |
31 ms |
12124 KB |
Output is correct |
10 |
Correct |
45 ms |
11920 KB |
Output is correct |
11 |
Correct |
40 ms |
12072 KB |
Output is correct |
12 |
Correct |
45 ms |
12112 KB |
Output is correct |
13 |
Correct |
46 ms |
12100 KB |
Output is correct |
14 |
Correct |
37 ms |
12140 KB |
Output is correct |
15 |
Correct |
52 ms |
12124 KB |
Output is correct |
16 |
Correct |
41 ms |
12068 KB |
Output is correct |
17 |
Correct |
34 ms |
11792 KB |
Output is correct |
18 |
Correct |
40 ms |
11900 KB |
Output is correct |
19 |
Correct |
30 ms |
12400 KB |
Output is correct |
20 |
Correct |
32 ms |
11896 KB |
Output is correct |
21 |
Correct |
37 ms |
11912 KB |
Output is correct |
22 |
Correct |
31 ms |
11876 KB |
Output is correct |
23 |
Correct |
26 ms |
10908 KB |
Output is correct |
24 |
Correct |
26 ms |
10928 KB |
Output is correct |
25 |
Correct |
34 ms |
11216 KB |
Output is correct |
26 |
Correct |
31 ms |
11164 KB |
Output is correct |
27 |
Correct |
32 ms |
11856 KB |
Output is correct |
28 |
Correct |
30 ms |
11940 KB |
Output is correct |
29 |
Correct |
31 ms |
11940 KB |
Output is correct |
30 |
Correct |
30 ms |
11992 KB |
Output is correct |
31 |
Correct |
33 ms |
10828 KB |
Output is correct |
32 |
Correct |
28 ms |
10912 KB |
Output is correct |
33 |
Correct |
27 ms |
11176 KB |
Output is correct |
34 |
Correct |
26 ms |
11184 KB |
Output is correct |
35 |
Correct |
28 ms |
11680 KB |
Output is correct |
36 |
Correct |
30 ms |
11664 KB |
Output is correct |
37 |
Correct |
32 ms |
11656 KB |
Output is correct |
38 |
Correct |
30 ms |
11676 KB |
Output is correct |
39 |
Correct |
31 ms |
11692 KB |
Output is correct |
40 |
Correct |
28 ms |
11640 KB |
Output is correct |
41 |
Correct |
31 ms |
11832 KB |
Output is correct |
42 |
Correct |
30 ms |
11896 KB |
Output is correct |
43 |
Correct |
30 ms |
11892 KB |
Output is correct |
44 |
Correct |
35 ms |
11980 KB |
Output is correct |
45 |
Correct |
30 ms |
12156 KB |
Output is correct |
46 |
Correct |
31 ms |
11904 KB |
Output is correct |
47 |
Correct |
33 ms |
11628 KB |
Output is correct |
48 |
Correct |
31 ms |
11592 KB |
Output is correct |
49 |
Correct |
28 ms |
11660 KB |
Output is correct |
50 |
Correct |
30 ms |
11648 KB |
Output is correct |
51 |
Correct |
25 ms |
11136 KB |
Output is correct |
52 |
Correct |
26 ms |
11136 KB |
Output is correct |
53 |
Correct |
27 ms |
11120 KB |
Output is correct |
54 |
Correct |
26 ms |
11144 KB |
Output is correct |
55 |
Correct |
28 ms |
11140 KB |
Output is correct |
56 |
Correct |
27 ms |
11128 KB |
Output is correct |
57 |
Correct |
25 ms |
11388 KB |
Output is correct |
58 |
Correct |
27 ms |
11380 KB |
Output is correct |
59 |
Correct |
27 ms |
11088 KB |
Output is correct |
60 |
Correct |
27 ms |
11188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
10920 KB |
Output is correct |
2 |
Correct |
30 ms |
11560 KB |
Output is correct |
3 |
Correct |
1 ms |
776 KB |
Output is correct |
4 |
Correct |
23 ms |
10612 KB |
Output is correct |
5 |
Correct |
32 ms |
12136 KB |
Output is correct |
6 |
Correct |
32 ms |
12128 KB |
Output is correct |
7 |
Correct |
30 ms |
11128 KB |
Output is correct |
8 |
Correct |
30 ms |
11520 KB |
Output is correct |
9 |
Correct |
32 ms |
11992 KB |
Output is correct |
10 |
Correct |
37 ms |
12204 KB |
Output is correct |
11 |
Correct |
31 ms |
12156 KB |
Output is correct |
12 |
Correct |
34 ms |
12164 KB |
Output is correct |
13 |
Correct |
38 ms |
12172 KB |
Output is correct |
14 |
Correct |
32 ms |
12168 KB |
Output is correct |
15 |
Correct |
32 ms |
12024 KB |
Output is correct |
16 |
Correct |
34 ms |
12160 KB |
Output is correct |
17 |
Correct |
30 ms |
11904 KB |
Output is correct |
18 |
Correct |
30 ms |
11864 KB |
Output is correct |
19 |
Correct |
32 ms |
11912 KB |
Output is correct |
20 |
Correct |
31 ms |
11884 KB |
Output is correct |
21 |
Correct |
31 ms |
11884 KB |
Output is correct |
22 |
Correct |
31 ms |
11904 KB |
Output is correct |
23 |
Correct |
27 ms |
10920 KB |
Output is correct |
24 |
Correct |
26 ms |
10920 KB |
Output is correct |
25 |
Correct |
28 ms |
11168 KB |
Output is correct |
26 |
Correct |
27 ms |
11180 KB |
Output is correct |
27 |
Correct |
28 ms |
11896 KB |
Output is correct |
28 |
Correct |
28 ms |
11808 KB |
Output is correct |
29 |
Correct |
30 ms |
11948 KB |
Output is correct |
30 |
Correct |
35 ms |
11920 KB |
Output is correct |
31 |
Correct |
25 ms |
10912 KB |
Output is correct |
32 |
Correct |
26 ms |
10912 KB |
Output is correct |
33 |
Correct |
28 ms |
11176 KB |
Output is correct |
34 |
Correct |
27 ms |
11180 KB |
Output is correct |
35 |
Correct |
31 ms |
11692 KB |
Output is correct |
36 |
Correct |
34 ms |
11888 KB |
Output is correct |
37 |
Correct |
28 ms |
11684 KB |
Output is correct |
38 |
Correct |
31 ms |
11696 KB |
Output is correct |
39 |
Correct |
31 ms |
11660 KB |
Output is correct |
40 |
Correct |
28 ms |
11620 KB |
Output is correct |
41 |
Correct |
30 ms |
11892 KB |
Output is correct |
42 |
Correct |
31 ms |
11900 KB |
Output is correct |
43 |
Correct |
30 ms |
11900 KB |
Output is correct |
44 |
Correct |
40 ms |
12080 KB |
Output is correct |
45 |
Correct |
36 ms |
12164 KB |
Output is correct |
46 |
Correct |
31 ms |
12148 KB |
Output is correct |
47 |
Correct |
31 ms |
11644 KB |
Output is correct |
48 |
Correct |
27 ms |
11912 KB |
Output is correct |
49 |
Correct |
31 ms |
11656 KB |
Output is correct |
50 |
Correct |
31 ms |
11656 KB |
Output is correct |
51 |
Correct |
27 ms |
11140 KB |
Output is correct |
52 |
Correct |
27 ms |
11164 KB |
Output is correct |
53 |
Correct |
32 ms |
11088 KB |
Output is correct |
54 |
Correct |
27 ms |
11128 KB |
Output is correct |
55 |
Correct |
27 ms |
11048 KB |
Output is correct |
56 |
Correct |
27 ms |
11124 KB |
Output is correct |
57 |
Correct |
27 ms |
11368 KB |
Output is correct |
58 |
Correct |
26 ms |
11428 KB |
Output is correct |
59 |
Correct |
27 ms |
11144 KB |
Output is correct |
60 |
Correct |
27 ms |
11244 KB |
Output is correct |