# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
748644 |
2023-05-26T16:52:01 Z |
piOOE |
Stray Cat (JOI20_stray) |
C++17 |
|
61 ms |
16872 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), ord;
dist[0] = 0;
queue<int> q;
q.push(0);
while (!q.empty()) {
int v = q.front();
q.pop();
ord.push_back(v);
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 (B == 0) {
for (int i = 0; i < M; ++i) {
if (dist[U[i]] > dist[V[i]]) {
swap(U[i], V[i]);
}
X[i] = dist[U[i]] % 3;
}
} else {
for (int i = 1; i < N; ++i) {
if (adj[i].size() > 2) {
for (auto [to, j] : adj[i]) {
X[j] = (dist[i] % 2) ^ (e[i] != j);
}
}
}
vector<int> code{0, 1, 1, 0, 0, 1};
vector<int> dp(N, -1);
reverse(ord.begin(), ord.end());
for (int x : ord) {
if (e[x] == -1 || X[e[x]] != -1) {
continue;
}
dp[x] = (dp[x] + 1) % size(code);
X[e[x]] = code[dp[x]];
dp[par[x]] = dp[x];
}
}
assert(find(X.begin(), X.end(), -1) == X.end());
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int A, B, e = -1;
bool ok = false;
vector<int> adj;
vector<int> code{0, 1, 1, 0, 0, 1};
bool extendable(vector<int> a) {
for (int i = 0; i < size(code); ++i) {
bool yay = true;
for (int k = 0; k < size(a); ++k) {
if (a[k] != code[(i + k) % size(code)]) {
yay = false;
break;
}
}
if (yay) {
return true;
}
}
return false;
}
}
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(std::vector<int> y) {
if (e != -1) {
y[e] += 1;
}
int deg = accumulate(y.begin(), y.end(), 0);
if (B == 0) {
int fi = -1, se = -1, cnt = 0;
for (int i = 0; i < A; ++i) {
if (y[i]) {
fi = fi == -1 ? i : fi;
se = i;
cnt += 1;
}
}
if (fi != 0 || se != 2) {
return e = fi;
} else {
return e = se;
}
} else {
if (size(adj) >= size(code)) {
ok = true;
}
if (deg > 2) {
ok = true;
for (int i = 0; i < A; ++i) {
if (y[i] == 1) {
if (i == e) {
return -1;
} else {
return e = i;
}
}
}
} else if (deg == 1) {
ok = true;
for (int i = 0; i < A; ++i) {
if (y[i]) {
if (i == e) {
return -1;
} else {
return e = i;
}
}
}
} else if (ok) {
--y[e];
for (int i = 0; i < A; ++i) {
if (y[i]) {
return e = i;
}
}
} else {
int a = -1, b = -1;
for (int i = 0; i < A; ++i) {
if (y[i]) {
a = a == -1 ? i : a;
b = i;
}
}
if (e == -1) {
adj.push_back(a);
adj.push_back(b);
return e = b;
}
int c = a ^ b ^ e;
adj.push_back(c);
if (extendable(adj)) {
return e = c;
} else {
ok = true;
return -1;
}
}
assert(false);
}
}
Compilation message
Catherine.cpp: In function 'bool {anonymous}::extendable(std::vector<int>)':
Catherine.cpp:14:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int i = 0; i < size(code); ++i) {
| ~~^~~~~~~~~~~~
Catherine.cpp:17:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for (int k = 0; k < size(a); ++k) {
| ~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
15928 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
35 ms |
15160 KB |
Output is correct |
4 |
Correct |
55 ms |
16832 KB |
Output is correct |
5 |
Correct |
52 ms |
16872 KB |
Output is correct |
6 |
Correct |
35 ms |
15624 KB |
Output is correct |
7 |
Correct |
35 ms |
15636 KB |
Output is correct |
8 |
Correct |
44 ms |
16396 KB |
Output is correct |
9 |
Correct |
41 ms |
16284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
15928 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
35 ms |
15160 KB |
Output is correct |
4 |
Correct |
55 ms |
16832 KB |
Output is correct |
5 |
Correct |
52 ms |
16872 KB |
Output is correct |
6 |
Correct |
35 ms |
15624 KB |
Output is correct |
7 |
Correct |
35 ms |
15636 KB |
Output is correct |
8 |
Correct |
44 ms |
16396 KB |
Output is correct |
9 |
Correct |
41 ms |
16284 KB |
Output is correct |
10 |
Correct |
37 ms |
13632 KB |
Output is correct |
11 |
Correct |
32 ms |
13604 KB |
Output is correct |
12 |
Correct |
32 ms |
13740 KB |
Output is correct |
13 |
Correct |
33 ms |
13592 KB |
Output is correct |
14 |
Correct |
35 ms |
13964 KB |
Output is correct |
15 |
Correct |
38 ms |
14204 KB |
Output is correct |
16 |
Correct |
44 ms |
16372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
13428 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
30 ms |
12920 KB |
Output is correct |
4 |
Correct |
43 ms |
14732 KB |
Output is correct |
5 |
Correct |
44 ms |
14712 KB |
Output is correct |
6 |
Correct |
38 ms |
13428 KB |
Output is correct |
7 |
Correct |
41 ms |
13424 KB |
Output is correct |
8 |
Correct |
45 ms |
14128 KB |
Output is correct |
9 |
Correct |
43 ms |
14108 KB |
Output is correct |
10 |
Correct |
39 ms |
13884 KB |
Output is correct |
11 |
Correct |
37 ms |
13924 KB |
Output is correct |
12 |
Correct |
43 ms |
13812 KB |
Output is correct |
13 |
Correct |
37 ms |
13896 KB |
Output is correct |
14 |
Correct |
45 ms |
13992 KB |
Output is correct |
15 |
Correct |
39 ms |
14128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
13428 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
30 ms |
12920 KB |
Output is correct |
4 |
Correct |
43 ms |
14732 KB |
Output is correct |
5 |
Correct |
44 ms |
14712 KB |
Output is correct |
6 |
Correct |
38 ms |
13428 KB |
Output is correct |
7 |
Correct |
41 ms |
13424 KB |
Output is correct |
8 |
Correct |
45 ms |
14128 KB |
Output is correct |
9 |
Correct |
43 ms |
14108 KB |
Output is correct |
10 |
Correct |
39 ms |
13884 KB |
Output is correct |
11 |
Correct |
37 ms |
13924 KB |
Output is correct |
12 |
Correct |
43 ms |
13812 KB |
Output is correct |
13 |
Correct |
37 ms |
13896 KB |
Output is correct |
14 |
Correct |
45 ms |
13992 KB |
Output is correct |
15 |
Correct |
39 ms |
14128 KB |
Output is correct |
16 |
Correct |
28 ms |
11756 KB |
Output is correct |
17 |
Correct |
28 ms |
11736 KB |
Output is correct |
18 |
Correct |
31 ms |
11868 KB |
Output is correct |
19 |
Correct |
33 ms |
11796 KB |
Output is correct |
20 |
Correct |
41 ms |
12420 KB |
Output is correct |
21 |
Correct |
33 ms |
12208 KB |
Output is correct |
22 |
Correct |
40 ms |
14160 KB |
Output is correct |
23 |
Correct |
32 ms |
11824 KB |
Output is correct |
24 |
Correct |
31 ms |
11916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
936 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
908 KB |
Output is correct |
4 |
Correct |
2 ms |
864 KB |
Output is correct |
5 |
Correct |
2 ms |
900 KB |
Output is correct |
6 |
Correct |
2 ms |
908 KB |
Output is correct |
7 |
Correct |
2 ms |
900 KB |
Output is correct |
8 |
Correct |
2 ms |
900 KB |
Output is correct |
9 |
Correct |
2 ms |
872 KB |
Output is correct |
10 |
Correct |
2 ms |
908 KB |
Output is correct |
11 |
Correct |
2 ms |
908 KB |
Output is correct |
12 |
Correct |
2 ms |
908 KB |
Output is correct |
13 |
Correct |
2 ms |
900 KB |
Output is correct |
14 |
Correct |
2 ms |
864 KB |
Output is correct |
15 |
Correct |
2 ms |
900 KB |
Output is correct |
16 |
Correct |
2 ms |
868 KB |
Output is correct |
17 |
Correct |
2 ms |
908 KB |
Output is correct |
18 |
Correct |
2 ms |
908 KB |
Output is correct |
19 |
Correct |
2 ms |
908 KB |
Output is correct |
20 |
Correct |
2 ms |
900 KB |
Output is correct |
21 |
Correct |
2 ms |
908 KB |
Output is correct |
22 |
Correct |
2 ms |
944 KB |
Output is correct |
23 |
Correct |
2 ms |
908 KB |
Output is correct |
24 |
Correct |
2 ms |
900 KB |
Output is correct |
25 |
Correct |
2 ms |
908 KB |
Output is correct |
26 |
Correct |
2 ms |
908 KB |
Output is correct |
27 |
Correct |
2 ms |
900 KB |
Output is correct |
28 |
Correct |
2 ms |
908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
11512 KB |
Output is correct |
2 |
Correct |
38 ms |
12012 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
29 ms |
11548 KB |
Output is correct |
5 |
Correct |
44 ms |
12644 KB |
Output is correct |
6 |
Correct |
46 ms |
12672 KB |
Output is correct |
7 |
Correct |
34 ms |
11832 KB |
Output is correct |
8 |
Correct |
38 ms |
11820 KB |
Output is correct |
9 |
Correct |
61 ms |
12816 KB |
Output is correct |
10 |
Correct |
58 ms |
12704 KB |
Output is correct |
11 |
Correct |
44 ms |
12660 KB |
Output is correct |
12 |
Correct |
43 ms |
12644 KB |
Output is correct |
13 |
Correct |
40 ms |
12644 KB |
Output is correct |
14 |
Correct |
48 ms |
12612 KB |
Output is correct |
15 |
Correct |
54 ms |
12652 KB |
Output is correct |
16 |
Correct |
44 ms |
12720 KB |
Output is correct |
17 |
Correct |
51 ms |
12256 KB |
Output is correct |
18 |
Correct |
44 ms |
12420 KB |
Output is correct |
19 |
Correct |
45 ms |
12324 KB |
Output is correct |
20 |
Correct |
45 ms |
12384 KB |
Output is correct |
21 |
Correct |
45 ms |
12312 KB |
Output is correct |
22 |
Correct |
44 ms |
12416 KB |
Output is correct |
23 |
Correct |
36 ms |
11544 KB |
Output is correct |
24 |
Correct |
33 ms |
11532 KB |
Output is correct |
25 |
Correct |
37 ms |
11696 KB |
Output is correct |
26 |
Correct |
45 ms |
11728 KB |
Output is correct |
27 |
Correct |
50 ms |
12164 KB |
Output is correct |
28 |
Correct |
38 ms |
12320 KB |
Output is correct |
29 |
Correct |
41 ms |
12096 KB |
Output is correct |
30 |
Correct |
39 ms |
12216 KB |
Output is correct |
31 |
Correct |
34 ms |
11520 KB |
Output is correct |
32 |
Correct |
32 ms |
11628 KB |
Output is correct |
33 |
Correct |
35 ms |
11624 KB |
Output is correct |
34 |
Correct |
32 ms |
11664 KB |
Output is correct |
35 |
Correct |
38 ms |
12044 KB |
Output is correct |
36 |
Correct |
41 ms |
12080 KB |
Output is correct |
37 |
Correct |
38 ms |
12076 KB |
Output is correct |
38 |
Correct |
41 ms |
12220 KB |
Output is correct |
39 |
Correct |
39 ms |
12032 KB |
Output is correct |
40 |
Correct |
46 ms |
12048 KB |
Output is correct |
41 |
Correct |
38 ms |
12244 KB |
Output is correct |
42 |
Correct |
39 ms |
12460 KB |
Output is correct |
43 |
Correct |
48 ms |
12260 KB |
Output is correct |
44 |
Correct |
39 ms |
12452 KB |
Output is correct |
45 |
Correct |
44 ms |
12360 KB |
Output is correct |
46 |
Correct |
43 ms |
12356 KB |
Output is correct |
47 |
Correct |
35 ms |
11992 KB |
Output is correct |
48 |
Correct |
48 ms |
12020 KB |
Output is correct |
49 |
Correct |
34 ms |
11844 KB |
Output is correct |
50 |
Correct |
34 ms |
12084 KB |
Output is correct |
51 |
Correct |
40 ms |
11788 KB |
Output is correct |
52 |
Correct |
32 ms |
11740 KB |
Output is correct |
53 |
Correct |
35 ms |
11772 KB |
Output is correct |
54 |
Correct |
31 ms |
11844 KB |
Output is correct |
55 |
Correct |
38 ms |
11752 KB |
Output is correct |
56 |
Correct |
33 ms |
11760 KB |
Output is correct |
57 |
Correct |
32 ms |
11480 KB |
Output is correct |
58 |
Correct |
33 ms |
11620 KB |
Output is correct |
59 |
Correct |
31 ms |
11688 KB |
Output is correct |
60 |
Incorrect |
29 ms |
11608 KB |
Wrong Answer [6] |
61 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
11496 KB |
Output is correct |
2 |
Correct |
34 ms |
11904 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
28 ms |
11524 KB |
Output is correct |
5 |
Correct |
41 ms |
12716 KB |
Output is correct |
6 |
Correct |
41 ms |
12584 KB |
Output is correct |
7 |
Correct |
36 ms |
11840 KB |
Output is correct |
8 |
Correct |
32 ms |
11828 KB |
Output is correct |
9 |
Correct |
39 ms |
12692 KB |
Output is correct |
10 |
Correct |
41 ms |
12784 KB |
Output is correct |
11 |
Correct |
39 ms |
12656 KB |
Output is correct |
12 |
Correct |
39 ms |
12660 KB |
Output is correct |
13 |
Correct |
39 ms |
12716 KB |
Output is correct |
14 |
Correct |
38 ms |
12708 KB |
Output is correct |
15 |
Correct |
38 ms |
12624 KB |
Output is correct |
16 |
Correct |
38 ms |
12728 KB |
Output is correct |
17 |
Correct |
40 ms |
12480 KB |
Output is correct |
18 |
Correct |
35 ms |
12416 KB |
Output is correct |
19 |
Correct |
36 ms |
12372 KB |
Output is correct |
20 |
Correct |
37 ms |
12400 KB |
Output is correct |
21 |
Correct |
41 ms |
12416 KB |
Output is correct |
22 |
Correct |
48 ms |
12420 KB |
Output is correct |
23 |
Correct |
31 ms |
11448 KB |
Output is correct |
24 |
Correct |
28 ms |
11648 KB |
Output is correct |
25 |
Correct |
32 ms |
11820 KB |
Output is correct |
26 |
Correct |
32 ms |
11784 KB |
Output is correct |
27 |
Correct |
36 ms |
12212 KB |
Output is correct |
28 |
Correct |
36 ms |
12172 KB |
Output is correct |
29 |
Correct |
35 ms |
12236 KB |
Output is correct |
30 |
Correct |
38 ms |
12136 KB |
Output is correct |
31 |
Incorrect |
29 ms |
11644 KB |
Wrong Answer [6] |
32 |
Halted |
0 ms |
0 KB |
- |