# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
748712 |
2023-05-26T18:44:35 Z |
piOOE |
Stray Cat (JOI20_stray) |
C++17 |
|
59 ms |
16340 KB |
#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;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
15312 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
32 ms |
14652 KB |
Output is correct |
4 |
Correct |
48 ms |
16296 KB |
Output is correct |
5 |
Correct |
45 ms |
16340 KB |
Output is correct |
6 |
Correct |
37 ms |
15056 KB |
Output is correct |
7 |
Correct |
37 ms |
15020 KB |
Output is correct |
8 |
Correct |
43 ms |
15764 KB |
Output is correct |
9 |
Correct |
41 ms |
15792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
15312 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
32 ms |
14652 KB |
Output is correct |
4 |
Correct |
48 ms |
16296 KB |
Output is correct |
5 |
Correct |
45 ms |
16340 KB |
Output is correct |
6 |
Correct |
37 ms |
15056 KB |
Output is correct |
7 |
Correct |
37 ms |
15020 KB |
Output is correct |
8 |
Correct |
43 ms |
15764 KB |
Output is correct |
9 |
Correct |
41 ms |
15792 KB |
Output is correct |
10 |
Correct |
34 ms |
13220 KB |
Output is correct |
11 |
Correct |
40 ms |
13000 KB |
Output is correct |
12 |
Correct |
31 ms |
13048 KB |
Output is correct |
13 |
Correct |
37 ms |
13092 KB |
Output is correct |
14 |
Correct |
33 ms |
13404 KB |
Output is correct |
15 |
Correct |
38 ms |
13648 KB |
Output is correct |
16 |
Correct |
41 ms |
15880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
12928 KB |
Output is correct |
2 |
Correct |
0 ms |
508 KB |
Output is correct |
3 |
Correct |
27 ms |
12520 KB |
Output is correct |
4 |
Correct |
44 ms |
14044 KB |
Output is correct |
5 |
Correct |
41 ms |
14112 KB |
Output is correct |
6 |
Correct |
33 ms |
12784 KB |
Output is correct |
7 |
Correct |
34 ms |
12924 KB |
Output is correct |
8 |
Correct |
41 ms |
13540 KB |
Output is correct |
9 |
Correct |
42 ms |
13480 KB |
Output is correct |
10 |
Correct |
36 ms |
13268 KB |
Output is correct |
11 |
Correct |
37 ms |
13284 KB |
Output is correct |
12 |
Correct |
37 ms |
13324 KB |
Output is correct |
13 |
Correct |
41 ms |
13304 KB |
Output is correct |
14 |
Correct |
40 ms |
13620 KB |
Output is correct |
15 |
Correct |
40 ms |
13504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
12928 KB |
Output is correct |
2 |
Correct |
0 ms |
508 KB |
Output is correct |
3 |
Correct |
27 ms |
12520 KB |
Output is correct |
4 |
Correct |
44 ms |
14044 KB |
Output is correct |
5 |
Correct |
41 ms |
14112 KB |
Output is correct |
6 |
Correct |
33 ms |
12784 KB |
Output is correct |
7 |
Correct |
34 ms |
12924 KB |
Output is correct |
8 |
Correct |
41 ms |
13540 KB |
Output is correct |
9 |
Correct |
42 ms |
13480 KB |
Output is correct |
10 |
Correct |
36 ms |
13268 KB |
Output is correct |
11 |
Correct |
37 ms |
13284 KB |
Output is correct |
12 |
Correct |
37 ms |
13324 KB |
Output is correct |
13 |
Correct |
41 ms |
13304 KB |
Output is correct |
14 |
Correct |
40 ms |
13620 KB |
Output is correct |
15 |
Correct |
40 ms |
13504 KB |
Output is correct |
16 |
Correct |
28 ms |
11304 KB |
Output is correct |
17 |
Correct |
32 ms |
11208 KB |
Output is correct |
18 |
Correct |
31 ms |
11176 KB |
Output is correct |
19 |
Correct |
30 ms |
11248 KB |
Output is correct |
20 |
Correct |
35 ms |
11808 KB |
Output is correct |
21 |
Correct |
33 ms |
11552 KB |
Output is correct |
22 |
Correct |
41 ms |
13740 KB |
Output is correct |
23 |
Correct |
37 ms |
11280 KB |
Output is correct |
24 |
Correct |
32 ms |
11320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
892 KB |
Output is correct |
2 |
Correct |
0 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
848 KB |
Output is correct |
4 |
Correct |
2 ms |
900 KB |
Output is correct |
5 |
Correct |
2 ms |
896 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 |
896 KB |
Output is correct |
11 |
Correct |
2 ms |
904 KB |
Output is correct |
12 |
Correct |
2 ms |
896 KB |
Output is correct |
13 |
Correct |
2 ms |
904 KB |
Output is correct |
14 |
Correct |
2 ms |
904 KB |
Output is correct |
15 |
Correct |
2 ms |
904 KB |
Output is correct |
16 |
Correct |
2 ms |
900 KB |
Output is correct |
17 |
Correct |
2 ms |
908 KB |
Output is correct |
18 |
Correct |
2 ms |
896 KB |
Output is correct |
19 |
Correct |
2 ms |
896 KB |
Output is correct |
20 |
Correct |
2 ms |
896 KB |
Output is correct |
21 |
Correct |
2 ms |
848 KB |
Output is correct |
22 |
Correct |
2 ms |
904 KB |
Output is correct |
23 |
Correct |
2 ms |
896 KB |
Output is correct |
24 |
Correct |
2 ms |
896 KB |
Output is correct |
25 |
Correct |
2 ms |
896 KB |
Output is correct |
26 |
Correct |
2 ms |
908 KB |
Output is correct |
27 |
Correct |
2 ms |
896 KB |
Output is correct |
28 |
Correct |
2 ms |
904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
11136 KB |
Output is correct |
2 |
Correct |
35 ms |
11428 KB |
Output is correct |
3 |
Correct |
0 ms |
508 KB |
Output is correct |
4 |
Correct |
28 ms |
10992 KB |
Output is correct |
5 |
Correct |
44 ms |
12092 KB |
Output is correct |
6 |
Correct |
44 ms |
12136 KB |
Output is correct |
7 |
Correct |
33 ms |
11260 KB |
Output is correct |
8 |
Correct |
34 ms |
11240 KB |
Output is correct |
9 |
Correct |
45 ms |
12088 KB |
Output is correct |
10 |
Correct |
48 ms |
12072 KB |
Output is correct |
11 |
Correct |
38 ms |
12060 KB |
Output is correct |
12 |
Correct |
39 ms |
12056 KB |
Output is correct |
13 |
Correct |
43 ms |
12144 KB |
Output is correct |
14 |
Correct |
41 ms |
12152 KB |
Output is correct |
15 |
Correct |
40 ms |
12060 KB |
Output is correct |
16 |
Correct |
41 ms |
12068 KB |
Output is correct |
17 |
Correct |
41 ms |
11824 KB |
Output is correct |
18 |
Correct |
39 ms |
11892 KB |
Output is correct |
19 |
Correct |
41 ms |
11716 KB |
Output is correct |
20 |
Correct |
39 ms |
11824 KB |
Output is correct |
21 |
Correct |
37 ms |
11716 KB |
Output is correct |
22 |
Correct |
36 ms |
11808 KB |
Output is correct |
23 |
Correct |
31 ms |
11212 KB |
Output is correct |
24 |
Correct |
31 ms |
11136 KB |
Output is correct |
25 |
Correct |
32 ms |
11200 KB |
Output is correct |
26 |
Correct |
35 ms |
11108 KB |
Output is correct |
27 |
Correct |
36 ms |
11612 KB |
Output is correct |
28 |
Correct |
37 ms |
11752 KB |
Output is correct |
29 |
Correct |
36 ms |
11608 KB |
Output is correct |
30 |
Correct |
37 ms |
11616 KB |
Output is correct |
31 |
Correct |
33 ms |
11048 KB |
Output is correct |
32 |
Correct |
31 ms |
11100 KB |
Output is correct |
33 |
Correct |
30 ms |
11176 KB |
Output is correct |
34 |
Correct |
32 ms |
11172 KB |
Output is correct |
35 |
Correct |
36 ms |
11556 KB |
Output is correct |
36 |
Correct |
35 ms |
11568 KB |
Output is correct |
37 |
Correct |
36 ms |
11640 KB |
Output is correct |
38 |
Correct |
36 ms |
11576 KB |
Output is correct |
39 |
Correct |
37 ms |
11548 KB |
Output is correct |
40 |
Correct |
35 ms |
11620 KB |
Output is correct |
41 |
Correct |
38 ms |
11912 KB |
Output is correct |
42 |
Correct |
36 ms |
11868 KB |
Output is correct |
43 |
Correct |
41 ms |
11792 KB |
Output is correct |
44 |
Correct |
38 ms |
11864 KB |
Output is correct |
45 |
Correct |
41 ms |
11884 KB |
Output is correct |
46 |
Correct |
37 ms |
11852 KB |
Output is correct |
47 |
Correct |
36 ms |
11412 KB |
Output is correct |
48 |
Correct |
34 ms |
11440 KB |
Output is correct |
49 |
Correct |
33 ms |
11380 KB |
Output is correct |
50 |
Correct |
35 ms |
11500 KB |
Output is correct |
51 |
Correct |
33 ms |
11324 KB |
Output is correct |
52 |
Correct |
31 ms |
11340 KB |
Output is correct |
53 |
Correct |
40 ms |
11336 KB |
Output is correct |
54 |
Correct |
36 ms |
11244 KB |
Output is correct |
55 |
Correct |
32 ms |
11396 KB |
Output is correct |
56 |
Correct |
32 ms |
11324 KB |
Output is correct |
57 |
Correct |
32 ms |
11248 KB |
Output is correct |
58 |
Correct |
33 ms |
11236 KB |
Output is correct |
59 |
Correct |
32 ms |
11208 KB |
Output is correct |
60 |
Correct |
32 ms |
11176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
11176 KB |
Output is correct |
2 |
Correct |
46 ms |
11352 KB |
Output is correct |
3 |
Correct |
0 ms |
508 KB |
Output is correct |
4 |
Correct |
28 ms |
11004 KB |
Output is correct |
5 |
Correct |
48 ms |
12068 KB |
Output is correct |
6 |
Correct |
48 ms |
12124 KB |
Output is correct |
7 |
Correct |
45 ms |
11188 KB |
Output is correct |
8 |
Correct |
51 ms |
11152 KB |
Output is correct |
9 |
Correct |
49 ms |
12068 KB |
Output is correct |
10 |
Correct |
57 ms |
12076 KB |
Output is correct |
11 |
Correct |
45 ms |
12056 KB |
Output is correct |
12 |
Correct |
45 ms |
12064 KB |
Output is correct |
13 |
Correct |
43 ms |
12080 KB |
Output is correct |
14 |
Correct |
43 ms |
12116 KB |
Output is correct |
15 |
Correct |
55 ms |
12108 KB |
Output is correct |
16 |
Correct |
52 ms |
12076 KB |
Output is correct |
17 |
Correct |
40 ms |
11800 KB |
Output is correct |
18 |
Correct |
47 ms |
11900 KB |
Output is correct |
19 |
Correct |
39 ms |
11856 KB |
Output is correct |
20 |
Correct |
41 ms |
11800 KB |
Output is correct |
21 |
Correct |
37 ms |
11824 KB |
Output is correct |
22 |
Correct |
48 ms |
11792 KB |
Output is correct |
23 |
Correct |
41 ms |
10960 KB |
Output is correct |
24 |
Correct |
36 ms |
10992 KB |
Output is correct |
25 |
Correct |
37 ms |
11164 KB |
Output is correct |
26 |
Correct |
35 ms |
11164 KB |
Output is correct |
27 |
Correct |
44 ms |
11584 KB |
Output is correct |
28 |
Correct |
38 ms |
11572 KB |
Output is correct |
29 |
Correct |
41 ms |
11540 KB |
Output is correct |
30 |
Correct |
53 ms |
11584 KB |
Output is correct |
31 |
Correct |
44 ms |
11156 KB |
Output is correct |
32 |
Correct |
40 ms |
11148 KB |
Output is correct |
33 |
Correct |
59 ms |
11128 KB |
Output is correct |
34 |
Correct |
41 ms |
11236 KB |
Output is correct |
35 |
Correct |
39 ms |
11556 KB |
Output is correct |
36 |
Correct |
45 ms |
11604 KB |
Output is correct |
37 |
Correct |
39 ms |
11572 KB |
Output is correct |
38 |
Correct |
44 ms |
11448 KB |
Output is correct |
39 |
Correct |
39 ms |
11556 KB |
Output is correct |
40 |
Correct |
37 ms |
11548 KB |
Output is correct |
41 |
Correct |
47 ms |
11784 KB |
Output is correct |
42 |
Correct |
59 ms |
11872 KB |
Output is correct |
43 |
Correct |
44 ms |
11796 KB |
Output is correct |
44 |
Correct |
38 ms |
11816 KB |
Output is correct |
45 |
Correct |
47 ms |
11752 KB |
Output is correct |
46 |
Correct |
48 ms |
11796 KB |
Output is correct |
47 |
Correct |
39 ms |
11472 KB |
Output is correct |
48 |
Correct |
43 ms |
11416 KB |
Output is correct |
49 |
Correct |
38 ms |
11304 KB |
Output is correct |
50 |
Correct |
45 ms |
11452 KB |
Output is correct |
51 |
Correct |
41 ms |
11284 KB |
Output is correct |
52 |
Correct |
34 ms |
11320 KB |
Output is correct |
53 |
Correct |
34 ms |
11312 KB |
Output is correct |
54 |
Correct |
37 ms |
11340 KB |
Output is correct |
55 |
Correct |
34 ms |
11324 KB |
Output is correct |
56 |
Correct |
39 ms |
11304 KB |
Output is correct |
57 |
Correct |
32 ms |
11192 KB |
Output is correct |
58 |
Correct |
36 ms |
11152 KB |
Output is correct |
59 |
Correct |
36 ms |
11164 KB |
Output is correct |
60 |
Correct |
41 ms |
11168 KB |
Output is correct |