#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> Mark(int N, int M, int A, int B,
std::vector<int> U, std::vector<int> V) {
std::vector<int> X(M, -1);
vector<vector<pair<int, int>>> adj(N);
for (int i = 0; i < M; ++i) {
adj[U[i]].push_back({V[i], i});
adj[V[i]].push_back({U[i], i});
}
vector<int> dist(N, -1), par(N), e(N, -1), dp(N, -1);
dist[0] = 0;
queue<int> q;
q.push(0);
while (!q.empty()) {
int v = q.front();
q.pop();
if (A == 2) {
int x = v;
if (par[x] && adj[par[x]].size() >= 3) {
if (X[e[par[x]]] == 1) {
dp[x] = 0;
} else {
dp[x] = 1;
}
} else if (x == 0) {
dp[x] = -1;
} else {
dp[x] = (1 + dp[par[x]]) % 6;
}
if (dp[x] >= 0) {
X[e[x]] = "010011"[dp[x]] - '0';
}
}
for (auto [to, i] : adj[v]) {
if (dist[to] == -1) {
dist[to] = dist[v] + 1;
par[to] = v;
e[to] = i;
q.push(to);
}
if (dist[to] >= dist[v] && A == 3) {
X[i] = dist[v] % 3;
}
}
}
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
string code = "010011", adj;
int A, B, e = -1;
bool known = false;
}
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(std::vector<int> y) {
vector<int> yy = y;
if (e != -1) {
yy[e] += 1;
}
int deg = accumulate(yy.begin(), yy.end(), 0);
if (A >= 3) {
int fi = -1, se = -1, cnt = 0;
for (int i = 0; i < A; ++i) {
if (yy[i]) {
fi = fi == -1 ? i : fi;
se = i;
cnt += 1;
}
}
if (fi != 0 || se != 2) {
return e = fi;
} else {
return e = se;
}
} else {
if (deg == 2) {
if (known) {
return e = find(y.begin(), y.end(), 1) - y.begin();
}
for (int i = 0; i < A; ++i) {
adj += string(y[i], char('0' + i));
}
if (adj.size() == 5) {
known = true;
string s = code + code;
for (int i = 0; i < 6; ++i) {
if (adj == s.substr(i, 5)) {
return -1;
}
}
return e = find(y.begin(), y.end(), 1) - y.begin();
} else {
return e = adj.back() - '0';
}
} else {
known = true;
int u = find(yy.begin(), yy.end(), 1) - yy.begin();
return u == e ? -1 : e = u;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
2452 KB |
Wrong Answer [2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
2452 KB |
Wrong Answer [2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
12736 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
30 ms |
12488 KB |
Output is correct |
4 |
Correct |
44 ms |
14140 KB |
Output is correct |
5 |
Correct |
45 ms |
14184 KB |
Output is correct |
6 |
Correct |
35 ms |
12916 KB |
Output is correct |
7 |
Correct |
33 ms |
12820 KB |
Output is correct |
8 |
Correct |
46 ms |
13464 KB |
Output is correct |
9 |
Correct |
40 ms |
13460 KB |
Output is correct |
10 |
Correct |
37 ms |
13276 KB |
Output is correct |
11 |
Correct |
37 ms |
13324 KB |
Output is correct |
12 |
Correct |
37 ms |
13276 KB |
Output is correct |
13 |
Correct |
45 ms |
13276 KB |
Output is correct |
14 |
Correct |
44 ms |
13588 KB |
Output is correct |
15 |
Correct |
39 ms |
13476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
12736 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
30 ms |
12488 KB |
Output is correct |
4 |
Correct |
44 ms |
14140 KB |
Output is correct |
5 |
Correct |
45 ms |
14184 KB |
Output is correct |
6 |
Correct |
35 ms |
12916 KB |
Output is correct |
7 |
Correct |
33 ms |
12820 KB |
Output is correct |
8 |
Correct |
46 ms |
13464 KB |
Output is correct |
9 |
Correct |
40 ms |
13460 KB |
Output is correct |
10 |
Correct |
37 ms |
13276 KB |
Output is correct |
11 |
Correct |
37 ms |
13324 KB |
Output is correct |
12 |
Correct |
37 ms |
13276 KB |
Output is correct |
13 |
Correct |
45 ms |
13276 KB |
Output is correct |
14 |
Correct |
44 ms |
13588 KB |
Output is correct |
15 |
Correct |
39 ms |
13476 KB |
Output is correct |
16 |
Correct |
32 ms |
11300 KB |
Output is correct |
17 |
Correct |
30 ms |
11352 KB |
Output is correct |
18 |
Correct |
30 ms |
11244 KB |
Output is correct |
19 |
Correct |
34 ms |
11236 KB |
Output is correct |
20 |
Correct |
38 ms |
11868 KB |
Output is correct |
21 |
Correct |
33 ms |
11620 KB |
Output is correct |
22 |
Correct |
46 ms |
13636 KB |
Output is correct |
23 |
Correct |
34 ms |
11284 KB |
Output is correct |
24 |
Correct |
31 ms |
11272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
896 KB |
Output is correct |
2 |
Correct |
0 ms |
520 KB |
Output is correct |
3 |
Correct |
2 ms |
904 KB |
Output is correct |
4 |
Correct |
2 ms |
896 KB |
Output is correct |
5 |
Correct |
2 ms |
904 KB |
Output is correct |
6 |
Correct |
2 ms |
904 KB |
Output is correct |
7 |
Correct |
2 ms |
896 KB |
Output is correct |
8 |
Correct |
2 ms |
896 KB |
Output is correct |
9 |
Correct |
2 ms |
896 KB |
Output is correct |
10 |
Correct |
2 ms |
904 KB |
Output is correct |
11 |
Correct |
2 ms |
904 KB |
Output is correct |
12 |
Correct |
2 ms |
892 KB |
Output is correct |
13 |
Correct |
2 ms |
896 KB |
Output is correct |
14 |
Correct |
2 ms |
896 KB |
Output is correct |
15 |
Correct |
2 ms |
896 KB |
Output is correct |
16 |
Correct |
2 ms |
896 KB |
Output is correct |
17 |
Correct |
2 ms |
904 KB |
Output is correct |
18 |
Correct |
2 ms |
908 KB |
Output is correct |
19 |
Correct |
2 ms |
896 KB |
Output is correct |
20 |
Correct |
2 ms |
844 KB |
Output is correct |
21 |
Correct |
2 ms |
896 KB |
Output is correct |
22 |
Correct |
2 ms |
896 KB |
Output is correct |
23 |
Correct |
2 ms |
896 KB |
Output is correct |
24 |
Correct |
2 ms |
904 KB |
Output is correct |
25 |
Correct |
2 ms |
904 KB |
Output is correct |
26 |
Correct |
2 ms |
904 KB |
Output is correct |
27 |
Correct |
2 ms |
904 KB |
Output is correct |
28 |
Correct |
2 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
11068 KB |
Output is correct |
2 |
Correct |
38 ms |
11420 KB |
Output is correct |
3 |
Correct |
0 ms |
516 KB |
Output is correct |
4 |
Correct |
28 ms |
10992 KB |
Output is correct |
5 |
Correct |
46 ms |
12000 KB |
Output is correct |
6 |
Correct |
48 ms |
12176 KB |
Output is correct |
7 |
Correct |
34 ms |
11240 KB |
Output is correct |
8 |
Correct |
36 ms |
11188 KB |
Output is correct |
9 |
Correct |
53 ms |
12048 KB |
Output is correct |
10 |
Correct |
41 ms |
12080 KB |
Output is correct |
11 |
Correct |
38 ms |
12132 KB |
Output is correct |
12 |
Correct |
40 ms |
12076 KB |
Output is correct |
13 |
Correct |
40 ms |
12084 KB |
Output is correct |
14 |
Correct |
43 ms |
12100 KB |
Output is correct |
15 |
Correct |
44 ms |
12188 KB |
Output is correct |
16 |
Correct |
40 ms |
12104 KB |
Output is correct |
17 |
Correct |
38 ms |
11828 KB |
Output is correct |
18 |
Correct |
37 ms |
11740 KB |
Output is correct |
19 |
Correct |
48 ms |
11720 KB |
Output is correct |
20 |
Correct |
43 ms |
11800 KB |
Output is correct |
21 |
Correct |
36 ms |
11764 KB |
Output is correct |
22 |
Correct |
36 ms |
11844 KB |
Output is correct |
23 |
Correct |
32 ms |
11216 KB |
Output is correct |
24 |
Correct |
31 ms |
11260 KB |
Output is correct |
25 |
Correct |
32 ms |
11208 KB |
Output is correct |
26 |
Correct |
31 ms |
11248 KB |
Output is correct |
27 |
Correct |
38 ms |
11540 KB |
Output is correct |
28 |
Correct |
40 ms |
11536 KB |
Output is correct |
29 |
Correct |
38 ms |
11560 KB |
Output is correct |
30 |
Correct |
36 ms |
11728 KB |
Output is correct |
31 |
Correct |
34 ms |
11172 KB |
Output is correct |
32 |
Correct |
42 ms |
11064 KB |
Output is correct |
33 |
Correct |
36 ms |
11108 KB |
Output is correct |
34 |
Correct |
34 ms |
11272 KB |
Output is correct |
35 |
Correct |
35 ms |
11556 KB |
Output is correct |
36 |
Correct |
35 ms |
11640 KB |
Output is correct |
37 |
Correct |
36 ms |
11644 KB |
Output is correct |
38 |
Correct |
36 ms |
11548 KB |
Output is correct |
39 |
Correct |
34 ms |
11556 KB |
Output is correct |
40 |
Correct |
39 ms |
11524 KB |
Output is correct |
41 |
Correct |
41 ms |
11820 KB |
Output is correct |
42 |
Correct |
43 ms |
11816 KB |
Output is correct |
43 |
Correct |
47 ms |
11744 KB |
Output is correct |
44 |
Correct |
36 ms |
11992 KB |
Output is correct |
45 |
Correct |
36 ms |
11836 KB |
Output is correct |
46 |
Correct |
37 ms |
11808 KB |
Output is correct |
47 |
Correct |
38 ms |
11404 KB |
Output is correct |
48 |
Correct |
56 ms |
11444 KB |
Output is correct |
49 |
Correct |
44 ms |
11340 KB |
Output is correct |
50 |
Correct |
40 ms |
11448 KB |
Output is correct |
51 |
Correct |
34 ms |
11224 KB |
Output is correct |
52 |
Correct |
39 ms |
11304 KB |
Output is correct |
53 |
Correct |
37 ms |
11220 KB |
Output is correct |
54 |
Correct |
45 ms |
11280 KB |
Output is correct |
55 |
Correct |
32 ms |
11368 KB |
Output is correct |
56 |
Correct |
35 ms |
11284 KB |
Output is correct |
57 |
Correct |
33 ms |
11384 KB |
Output is correct |
58 |
Correct |
32 ms |
11300 KB |
Output is correct |
59 |
Correct |
34 ms |
11188 KB |
Output is correct |
60 |
Correct |
33 ms |
11404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
10928 KB |
Output is correct |
2 |
Correct |
35 ms |
11388 KB |
Output is correct |
3 |
Correct |
0 ms |
516 KB |
Output is correct |
4 |
Correct |
27 ms |
10988 KB |
Output is correct |
5 |
Correct |
43 ms |
12104 KB |
Output is correct |
6 |
Correct |
39 ms |
12140 KB |
Output is correct |
7 |
Correct |
32 ms |
11252 KB |
Output is correct |
8 |
Correct |
31 ms |
11260 KB |
Output is correct |
9 |
Correct |
41 ms |
12188 KB |
Output is correct |
10 |
Correct |
44 ms |
12064 KB |
Output is correct |
11 |
Correct |
46 ms |
12052 KB |
Output is correct |
12 |
Correct |
41 ms |
12104 KB |
Output is correct |
13 |
Correct |
41 ms |
12072 KB |
Output is correct |
14 |
Correct |
41 ms |
12104 KB |
Output is correct |
15 |
Correct |
39 ms |
12124 KB |
Output is correct |
16 |
Correct |
46 ms |
12124 KB |
Output is correct |
17 |
Correct |
44 ms |
11704 KB |
Output is correct |
18 |
Correct |
38 ms |
11796 KB |
Output is correct |
19 |
Correct |
42 ms |
11812 KB |
Output is correct |
20 |
Correct |
51 ms |
11792 KB |
Output is correct |
21 |
Correct |
40 ms |
11872 KB |
Output is correct |
22 |
Correct |
37 ms |
11864 KB |
Output is correct |
23 |
Correct |
28 ms |
11240 KB |
Output is correct |
24 |
Correct |
40 ms |
10956 KB |
Output is correct |
25 |
Correct |
42 ms |
11172 KB |
Output is correct |
26 |
Correct |
31 ms |
11256 KB |
Output is correct |
27 |
Correct |
35 ms |
11612 KB |
Output is correct |
28 |
Correct |
35 ms |
11600 KB |
Output is correct |
29 |
Correct |
36 ms |
11676 KB |
Output is correct |
30 |
Correct |
35 ms |
11556 KB |
Output is correct |
31 |
Correct |
31 ms |
11120 KB |
Output is correct |
32 |
Correct |
31 ms |
11096 KB |
Output is correct |
33 |
Correct |
33 ms |
11168 KB |
Output is correct |
34 |
Correct |
34 ms |
11208 KB |
Output is correct |
35 |
Correct |
41 ms |
11580 KB |
Output is correct |
36 |
Correct |
40 ms |
11600 KB |
Output is correct |
37 |
Correct |
34 ms |
11652 KB |
Output is correct |
38 |
Correct |
35 ms |
11536 KB |
Output is correct |
39 |
Correct |
36 ms |
11636 KB |
Output is correct |
40 |
Correct |
36 ms |
11592 KB |
Output is correct |
41 |
Correct |
36 ms |
11864 KB |
Output is correct |
42 |
Correct |
36 ms |
11848 KB |
Output is correct |
43 |
Correct |
40 ms |
11788 KB |
Output is correct |
44 |
Correct |
37 ms |
11912 KB |
Output is correct |
45 |
Correct |
43 ms |
11876 KB |
Output is correct |
46 |
Correct |
56 ms |
11804 KB |
Output is correct |
47 |
Correct |
34 ms |
11484 KB |
Output is correct |
48 |
Correct |
34 ms |
11452 KB |
Output is correct |
49 |
Correct |
35 ms |
11360 KB |
Output is correct |
50 |
Correct |
50 ms |
11440 KB |
Output is correct |
51 |
Correct |
37 ms |
11324 KB |
Output is correct |
52 |
Correct |
32 ms |
11348 KB |
Output is correct |
53 |
Correct |
32 ms |
11356 KB |
Output is correct |
54 |
Correct |
31 ms |
11324 KB |
Output is correct |
55 |
Correct |
33 ms |
11368 KB |
Output is correct |
56 |
Correct |
33 ms |
11364 KB |
Output is correct |
57 |
Correct |
33 ms |
11232 KB |
Output is correct |
58 |
Correct |
33 ms |
11252 KB |
Output is correct |
59 |
Correct |
32 ms |
11228 KB |
Output is correct |
60 |
Correct |
34 ms |
11244 KB |
Output is correct |