# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
927543 |
2024-02-15T03:22:59 Z |
CDuong |
Stray Cat (JOI20_stray) |
C++17 |
|
41 ms |
16752 KB |
#include "Anthony.h"
#include<bits/stdc++.h>
using namespace std;
namespace {
int chain[] = {0, 1, 0, 0, 1, 1};
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
vector<vector<int>> G(N);
for (int i = 0; i < M; ++i) {
G[U[i]].emplace_back(V[i]);
G[V[i]].emplace_back(U[i]);
}
vector<int> dis(N, INT_MAX), color(N);
queue<int> q;
dis[0] = 0; q.emplace(0);
while (not q.empty()) {
int u = q.front(); q.pop();
for (int v : G[u]) if (dis[v] > dis[u] + 1) {
if (A == 2) {
if (u == 0) color[v] = 0;
else if ((int)G[u].size() >= 3) color[v] = !chain[color[u]];
else color[v] = (color[u] + 1) % 6;
}
dis[v] = dis[u] + 1;
q.emplace(v);
}
}
vector<int> res(M);
for (int i = 0; i < M; ++i) {
int u, v;
tie(u, v) = tie(U[i], V[i]);
if (dis[u] > dis[v]) swap(u, v);
if (A == 2) res[i] = chain[color[v]];
else res[i] = dis[u] % 3;
}
// for (int val : res) cout << val << " ";
// cout << endl;
return res;
}
#include "Catherine.h"
#include<bits/stdc++.h>
using namespace std;
namespace {
int A, B;
int last = -1;
bool flag = false;
vector<int> vec;
vector<int> chain = {0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1};
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(vector<int> cnt) {
if (A != 2) {
if (last != -1) ++cnt[last];
int ap = 0;
for (int val : cnt) ap += !!val;
if (ap == 1) for (int i = 0; i < 3; ++i) if (cnt[i]) return last = i;
if (cnt[0] == 0) return last = 1;
if (cnt[1] == 0) return last = 2;
if (cnt[2] == 0) return last = 0;
}
int deg = (last != -1);
for (int i = 0; i < 2; ++i) deg += cnt[i];
if (deg == 2) {
if (flag) {
for (int i = 0; i < 2; ++i) if (cnt[i] == 1) return last = i;
}
for (int i = 0; i < 2; ++i) {
for (int _ = 0; _ < cnt[i]; ++_) vec.emplace_back(i);
}
if ((int)vec.size() == 5) {
flag = true;
bool way = false;
for (int i = 0; i <= (int)chain.size() - (int)vec.size(); ++i) {
int ccnt = 0;
for (int j = 0; j < (int)vec.size(); ++j) ccnt += vec[j] == chain[i + j];
way |= ccnt == (int)vec.size();
}
if (way) return -1;
for (int i = 0; i < 2; ++i) if (cnt[i] == 1) return last = i;
}
else return last = vec.back();
}
else {
flag = true;
if (last != -1) ++cnt[last];
for (int i = 0; i < 2; ++i) if (cnt[i] == 1) {
if (last == i) return -1;
else return last = i;
}
}
}
Compilation message
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
62 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
15080 KB |
Output is correct |
2 |
Correct |
0 ms |
792 KB |
Output is correct |
3 |
Correct |
24 ms |
15012 KB |
Output is correct |
4 |
Correct |
33 ms |
16748 KB |
Output is correct |
5 |
Correct |
38 ms |
16696 KB |
Output is correct |
6 |
Correct |
26 ms |
15440 KB |
Output is correct |
7 |
Correct |
26 ms |
15480 KB |
Output is correct |
8 |
Correct |
31 ms |
16200 KB |
Output is correct |
9 |
Correct |
37 ms |
16656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
15080 KB |
Output is correct |
2 |
Correct |
0 ms |
792 KB |
Output is correct |
3 |
Correct |
24 ms |
15012 KB |
Output is correct |
4 |
Correct |
33 ms |
16748 KB |
Output is correct |
5 |
Correct |
38 ms |
16696 KB |
Output is correct |
6 |
Correct |
26 ms |
15440 KB |
Output is correct |
7 |
Correct |
26 ms |
15480 KB |
Output is correct |
8 |
Correct |
31 ms |
16200 KB |
Output is correct |
9 |
Correct |
37 ms |
16656 KB |
Output is correct |
10 |
Correct |
25 ms |
13656 KB |
Output is correct |
11 |
Correct |
27 ms |
13656 KB |
Output is correct |
12 |
Correct |
26 ms |
13640 KB |
Output is correct |
13 |
Correct |
26 ms |
13644 KB |
Output is correct |
14 |
Correct |
26 ms |
13696 KB |
Output is correct |
15 |
Correct |
41 ms |
13892 KB |
Output is correct |
16 |
Correct |
32 ms |
16752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
12688 KB |
Output is correct |
2 |
Correct |
1 ms |
784 KB |
Output is correct |
3 |
Correct |
22 ms |
12872 KB |
Output is correct |
4 |
Correct |
32 ms |
14668 KB |
Output is correct |
5 |
Correct |
32 ms |
14720 KB |
Output is correct |
6 |
Correct |
29 ms |
13180 KB |
Output is correct |
7 |
Correct |
26 ms |
13192 KB |
Output is correct |
8 |
Correct |
31 ms |
13904 KB |
Output is correct |
9 |
Correct |
31 ms |
13908 KB |
Output is correct |
10 |
Correct |
27 ms |
13732 KB |
Output is correct |
11 |
Correct |
32 ms |
13676 KB |
Output is correct |
12 |
Correct |
30 ms |
13688 KB |
Output is correct |
13 |
Correct |
35 ms |
13680 KB |
Output is correct |
14 |
Correct |
31 ms |
14024 KB |
Output is correct |
15 |
Correct |
30 ms |
13944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
12688 KB |
Output is correct |
2 |
Correct |
1 ms |
784 KB |
Output is correct |
3 |
Correct |
22 ms |
12872 KB |
Output is correct |
4 |
Correct |
32 ms |
14668 KB |
Output is correct |
5 |
Correct |
32 ms |
14720 KB |
Output is correct |
6 |
Correct |
29 ms |
13180 KB |
Output is correct |
7 |
Correct |
26 ms |
13192 KB |
Output is correct |
8 |
Correct |
31 ms |
13904 KB |
Output is correct |
9 |
Correct |
31 ms |
13908 KB |
Output is correct |
10 |
Correct |
27 ms |
13732 KB |
Output is correct |
11 |
Correct |
32 ms |
13676 KB |
Output is correct |
12 |
Correct |
30 ms |
13688 KB |
Output is correct |
13 |
Correct |
35 ms |
13680 KB |
Output is correct |
14 |
Correct |
31 ms |
14024 KB |
Output is correct |
15 |
Correct |
30 ms |
13944 KB |
Output is correct |
16 |
Correct |
26 ms |
11592 KB |
Output is correct |
17 |
Correct |
27 ms |
11548 KB |
Output is correct |
18 |
Correct |
25 ms |
11680 KB |
Output is correct |
19 |
Correct |
24 ms |
11520 KB |
Output is correct |
20 |
Correct |
26 ms |
12296 KB |
Output is correct |
21 |
Correct |
26 ms |
11952 KB |
Output is correct |
22 |
Correct |
28 ms |
14220 KB |
Output is correct |
23 |
Correct |
25 ms |
11872 KB |
Output is correct |
24 |
Correct |
28 ms |
12124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1052 KB |
Output is correct |
2 |
Correct |
0 ms |
780 KB |
Output is correct |
3 |
Correct |
1 ms |
1040 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 |
1052 KB |
Output is correct |
7 |
Correct |
2 ms |
1036 KB |
Output is correct |
8 |
Correct |
2 ms |
1048 KB |
Output is correct |
9 |
Correct |
2 ms |
1044 KB |
Output is correct |
10 |
Correct |
1 ms |
1052 KB |
Output is correct |
11 |
Correct |
0 ms |
1052 KB |
Output is correct |
12 |
Correct |
2 ms |
1044 KB |
Output is correct |
13 |
Correct |
0 ms |
1048 KB |
Output is correct |
14 |
Correct |
0 ms |
1052 KB |
Output is correct |
15 |
Correct |
2 ms |
1044 KB |
Output is correct |
16 |
Correct |
2 ms |
1048 KB |
Output is correct |
17 |
Correct |
0 ms |
1052 KB |
Output is correct |
18 |
Correct |
1 ms |
1052 KB |
Output is correct |
19 |
Correct |
1 ms |
1296 KB |
Output is correct |
20 |
Correct |
1 ms |
1044 KB |
Output is correct |
21 |
Correct |
2 ms |
1052 KB |
Output is correct |
22 |
Correct |
1 ms |
1048 KB |
Output is correct |
23 |
Correct |
2 ms |
1052 KB |
Output is correct |
24 |
Correct |
1 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 |
1 ms |
1044 KB |
Output is correct |
28 |
Correct |
2 ms |
1048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
11128 KB |
Output is correct |
2 |
Correct |
26 ms |
11436 KB |
Output is correct |
3 |
Correct |
0 ms |
780 KB |
Output is correct |
4 |
Correct |
22 ms |
10952 KB |
Output is correct |
5 |
Correct |
34 ms |
12432 KB |
Output is correct |
6 |
Correct |
28 ms |
12168 KB |
Output is correct |
7 |
Correct |
30 ms |
11168 KB |
Output is correct |
8 |
Correct |
26 ms |
11344 KB |
Output is correct |
9 |
Correct |
31 ms |
12192 KB |
Output is correct |
10 |
Correct |
30 ms |
12196 KB |
Output is correct |
11 |
Correct |
28 ms |
12204 KB |
Output is correct |
12 |
Correct |
30 ms |
12204 KB |
Output is correct |
13 |
Correct |
33 ms |
12184 KB |
Output is correct |
14 |
Correct |
30 ms |
12100 KB |
Output is correct |
15 |
Correct |
30 ms |
12196 KB |
Output is correct |
16 |
Correct |
28 ms |
12204 KB |
Output is correct |
17 |
Correct |
27 ms |
11952 KB |
Output is correct |
18 |
Correct |
30 ms |
11748 KB |
Output is correct |
19 |
Correct |
27 ms |
11940 KB |
Output is correct |
20 |
Correct |
27 ms |
11776 KB |
Output is correct |
21 |
Correct |
27 ms |
11792 KB |
Output is correct |
22 |
Correct |
27 ms |
11944 KB |
Output is correct |
23 |
Correct |
24 ms |
10932 KB |
Output is correct |
24 |
Correct |
24 ms |
10916 KB |
Output is correct |
25 |
Correct |
25 ms |
11144 KB |
Output is correct |
26 |
Correct |
25 ms |
11188 KB |
Output is correct |
27 |
Correct |
27 ms |
11428 KB |
Output is correct |
28 |
Correct |
26 ms |
11420 KB |
Output is correct |
29 |
Correct |
26 ms |
11436 KB |
Output is correct |
30 |
Correct |
34 ms |
11348 KB |
Output is correct |
31 |
Correct |
24 ms |
10880 KB |
Output is correct |
32 |
Correct |
26 ms |
11320 KB |
Output is correct |
33 |
Correct |
25 ms |
10984 KB |
Output is correct |
34 |
Correct |
28 ms |
11084 KB |
Output is correct |
35 |
Correct |
26 ms |
11484 KB |
Output is correct |
36 |
Correct |
26 ms |
11348 KB |
Output is correct |
37 |
Correct |
26 ms |
11428 KB |
Output is correct |
38 |
Correct |
26 ms |
11356 KB |
Output is correct |
39 |
Correct |
30 ms |
11500 KB |
Output is correct |
40 |
Correct |
26 ms |
11420 KB |
Output is correct |
41 |
Correct |
30 ms |
11676 KB |
Output is correct |
42 |
Correct |
27 ms |
11636 KB |
Output is correct |
43 |
Correct |
27 ms |
11700 KB |
Output is correct |
44 |
Correct |
27 ms |
11696 KB |
Output is correct |
45 |
Correct |
37 ms |
11680 KB |
Output is correct |
46 |
Correct |
27 ms |
11696 KB |
Output is correct |
47 |
Correct |
26 ms |
11416 KB |
Output is correct |
48 |
Correct |
26 ms |
11432 KB |
Output is correct |
49 |
Correct |
26 ms |
11180 KB |
Output is correct |
50 |
Correct |
26 ms |
11432 KB |
Output is correct |
51 |
Correct |
30 ms |
11120 KB |
Output is correct |
52 |
Correct |
26 ms |
11192 KB |
Output is correct |
53 |
Correct |
25 ms |
11180 KB |
Output is correct |
54 |
Correct |
24 ms |
11180 KB |
Output is correct |
55 |
Correct |
26 ms |
11156 KB |
Output is correct |
56 |
Correct |
25 ms |
11176 KB |
Output is correct |
57 |
Correct |
28 ms |
11164 KB |
Output is correct |
58 |
Correct |
27 ms |
11256 KB |
Output is correct |
59 |
Correct |
25 ms |
11184 KB |
Output is correct |
60 |
Correct |
25 ms |
11072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
10900 KB |
Output is correct |
2 |
Correct |
31 ms |
11084 KB |
Output is correct |
3 |
Correct |
0 ms |
792 KB |
Output is correct |
4 |
Correct |
20 ms |
11012 KB |
Output is correct |
5 |
Correct |
34 ms |
12200 KB |
Output is correct |
6 |
Correct |
32 ms |
12188 KB |
Output is correct |
7 |
Correct |
25 ms |
11376 KB |
Output is correct |
8 |
Correct |
27 ms |
11344 KB |
Output is correct |
9 |
Correct |
30 ms |
12292 KB |
Output is correct |
10 |
Correct |
30 ms |
12200 KB |
Output is correct |
11 |
Correct |
39 ms |
12176 KB |
Output is correct |
12 |
Correct |
28 ms |
12204 KB |
Output is correct |
13 |
Correct |
28 ms |
12204 KB |
Output is correct |
14 |
Correct |
28 ms |
12176 KB |
Output is correct |
15 |
Correct |
31 ms |
12180 KB |
Output is correct |
16 |
Correct |
28 ms |
12448 KB |
Output is correct |
17 |
Correct |
28 ms |
11936 KB |
Output is correct |
18 |
Correct |
33 ms |
11948 KB |
Output is correct |
19 |
Correct |
27 ms |
11936 KB |
Output is correct |
20 |
Correct |
28 ms |
11944 KB |
Output is correct |
21 |
Correct |
27 ms |
11948 KB |
Output is correct |
22 |
Correct |
28 ms |
11948 KB |
Output is correct |
23 |
Correct |
25 ms |
10928 KB |
Output is correct |
24 |
Correct |
24 ms |
10920 KB |
Output is correct |
25 |
Correct |
27 ms |
11336 KB |
Output is correct |
26 |
Correct |
25 ms |
11172 KB |
Output is correct |
27 |
Correct |
26 ms |
11356 KB |
Output is correct |
28 |
Correct |
27 ms |
11380 KB |
Output is correct |
29 |
Correct |
26 ms |
11440 KB |
Output is correct |
30 |
Correct |
26 ms |
11440 KB |
Output is correct |
31 |
Correct |
25 ms |
10864 KB |
Output is correct |
32 |
Correct |
24 ms |
11136 KB |
Output is correct |
33 |
Correct |
25 ms |
11132 KB |
Output is correct |
34 |
Correct |
25 ms |
11176 KB |
Output is correct |
35 |
Correct |
26 ms |
11456 KB |
Output is correct |
36 |
Correct |
26 ms |
11436 KB |
Output is correct |
37 |
Correct |
30 ms |
11552 KB |
Output is correct |
38 |
Correct |
26 ms |
11444 KB |
Output is correct |
39 |
Correct |
26 ms |
11424 KB |
Output is correct |
40 |
Correct |
26 ms |
11444 KB |
Output is correct |
41 |
Correct |
30 ms |
11672 KB |
Output is correct |
42 |
Correct |
27 ms |
11680 KB |
Output is correct |
43 |
Correct |
34 ms |
11928 KB |
Output is correct |
44 |
Correct |
27 ms |
11692 KB |
Output is correct |
45 |
Correct |
27 ms |
11684 KB |
Output is correct |
46 |
Correct |
30 ms |
11640 KB |
Output is correct |
47 |
Correct |
26 ms |
11440 KB |
Output is correct |
48 |
Correct |
26 ms |
11436 KB |
Output is correct |
49 |
Correct |
26 ms |
11184 KB |
Output is correct |
50 |
Correct |
27 ms |
11436 KB |
Output is correct |
51 |
Correct |
24 ms |
11188 KB |
Output is correct |
52 |
Correct |
25 ms |
11184 KB |
Output is correct |
53 |
Correct |
25 ms |
11168 KB |
Output is correct |
54 |
Correct |
25 ms |
11180 KB |
Output is correct |
55 |
Correct |
24 ms |
11320 KB |
Output is correct |
56 |
Correct |
25 ms |
11152 KB |
Output is correct |
57 |
Correct |
25 ms |
11084 KB |
Output is correct |
58 |
Correct |
25 ms |
11164 KB |
Output is correct |
59 |
Correct |
24 ms |
11180 KB |
Output is correct |
60 |
Correct |
25 ms |
11172 KB |
Output is correct |