# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1042188 |
2024-08-02T15:50:56 Z |
juicy |
Stray Cat (JOI20_stray) |
C++17 |
|
32 ms |
17252 KB |
// https://www2.ioi-jp.org/camp/2020/2020-sp-tasks/day3/stray-review.pdf
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
void __print() {
cerr << "]\n";
}
template<class T, class... V>
void __print(T t, V... v) {
cerr << t;
if (sizeof...(v)) {
cerr << ", ";
}
__print(v...);
}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; __print(x);
#else
#define debug(...) 42
#endif
vector<int> clr, dep;
vector<vector<int>> g;
string S = "010011";
} // namespace
std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) {
clr.resize(N);
g.resize(N);
dep.resize(N, -1);
for (int i = 0; i < M; ++i) {
int u = U[i], v = V[i];
g[u].push_back(v);
g[v].push_back(u);
}
queue<int> q;
dep[0] = 0;
q.push(0);
while (q.size()) {
int u = q.front(); q.pop();
for (int v : g[u]) {
if (dep[v] == -1) {
dep[v] = dep[u] + 1;
if (A == 2) {
if (u == 0) {
clr[v] = 0;
} else if (g[u].size() == 2) {
clr[v] = (clr[u] + 1) % 6;
} else {
clr[v] = S[clr[u]] == '0';
}
}
q.push(v);
}
}
}
vector<int> X(M);
for (int i = 0; i < M; ++i) {
int u = U[i], v = V[i];
if (dep[u] < dep[v]) {
swap(u, v);
}
if (A == 2) {
X[i] = S[clr[u]] - '0';
} else {
X[i] = dep[v] % 3;
}
}
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
template<class T>
ostream &operator << (ostream &os, vector<T> v) {
for (int i = 0; i < v.size(); ++i) {
os << (i ? ", " : "{") << v[i];
}
return os << "}";
}
void __print() {
cerr << "]\n";
}
template<class T, class... V>
void __print(T t, V... v) {
cerr << t;
if (sizeof...(v)) {
cerr << ", ";
}
__print(v...);
}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; __print(x);
#else
#define debug(...) 42
#endif
int A, B, lst = -1;
bool up;
string S;
bool check() {
for (int i = 0; i < 6; ++i) {
if (string("010011010011").substr(i, 5) == S) {
return 1;
}
}
return 0;
}
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(std::vector<int> y) {
auto g = y;
if (~lst) {
++g[lst];
}
int deg = 0, cnt = 0;
for (int i = 0; i < A; ++i) {
deg += g[i];
cnt += g[i] > 0;
}
if (A == 2) {
if (deg == 2) {
if (up) {
return lst = find(y.begin(), y.end(), 1) - y.begin();
}
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < y[i]; ++j) {
S += i + '0';
}
}
if (S.size() == 5) {
up = 1;
return check() ? -1 : lst = S.back() - '0';
}
return lst = S.back() - '0';
}
up = 1;
int nxt = find(g.begin(), g.end(), 1) - g.begin();
return lst == nxt ? -1 : lst = nxt;
}
if (cnt == 1) {
for (int i = 0; i < 3; ++i) {
if (y[i]) {
return lst = i;
}
}
}
if (lst == -1) {
for (int i = 0; i < 3; ++i) {
if (y[i] == 0) {
return lst = (i + 1) % 3;
}
}
}
int nxt = lst == 0 ? 2 : lst - 1;
assert(y[nxt]);
return lst = nxt;
}
Compilation message
Anthony.cpp:10:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
10 | void __print() {
| ^~~~~~~
Catherine.cpp:16:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
16 | void __print() {
| ^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
16224 KB |
Output is correct |
2 |
Correct |
1 ms |
792 KB |
Output is correct |
3 |
Correct |
20 ms |
15924 KB |
Output is correct |
4 |
Correct |
27 ms |
17244 KB |
Output is correct |
5 |
Correct |
26 ms |
17252 KB |
Output is correct |
6 |
Correct |
23 ms |
15960 KB |
Output is correct |
7 |
Correct |
22 ms |
15852 KB |
Output is correct |
8 |
Correct |
31 ms |
16716 KB |
Output is correct |
9 |
Correct |
26 ms |
16736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
16224 KB |
Output is correct |
2 |
Correct |
1 ms |
792 KB |
Output is correct |
3 |
Correct |
20 ms |
15924 KB |
Output is correct |
4 |
Correct |
27 ms |
17244 KB |
Output is correct |
5 |
Correct |
26 ms |
17252 KB |
Output is correct |
6 |
Correct |
23 ms |
15960 KB |
Output is correct |
7 |
Correct |
22 ms |
15852 KB |
Output is correct |
8 |
Correct |
31 ms |
16716 KB |
Output is correct |
9 |
Correct |
26 ms |
16736 KB |
Output is correct |
10 |
Correct |
24 ms |
13896 KB |
Output is correct |
11 |
Correct |
26 ms |
13880 KB |
Output is correct |
12 |
Correct |
23 ms |
13904 KB |
Output is correct |
13 |
Correct |
22 ms |
13908 KB |
Output is correct |
14 |
Correct |
22 ms |
14156 KB |
Output is correct |
15 |
Correct |
26 ms |
14336 KB |
Output is correct |
16 |
Correct |
31 ms |
16724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
13668 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
21 ms |
13076 KB |
Output is correct |
4 |
Correct |
28 ms |
15184 KB |
Output is correct |
5 |
Correct |
26 ms |
15028 KB |
Output is correct |
6 |
Correct |
21 ms |
13668 KB |
Output is correct |
7 |
Correct |
22 ms |
13656 KB |
Output is correct |
8 |
Correct |
27 ms |
14352 KB |
Output is correct |
9 |
Correct |
24 ms |
14420 KB |
Output is correct |
10 |
Correct |
26 ms |
14256 KB |
Output is correct |
11 |
Correct |
23 ms |
14160 KB |
Output is correct |
12 |
Correct |
23 ms |
14156 KB |
Output is correct |
13 |
Correct |
23 ms |
14168 KB |
Output is correct |
14 |
Correct |
24 ms |
14256 KB |
Output is correct |
15 |
Correct |
25 ms |
14428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
13668 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
21 ms |
13076 KB |
Output is correct |
4 |
Correct |
28 ms |
15184 KB |
Output is correct |
5 |
Correct |
26 ms |
15028 KB |
Output is correct |
6 |
Correct |
21 ms |
13668 KB |
Output is correct |
7 |
Correct |
22 ms |
13656 KB |
Output is correct |
8 |
Correct |
27 ms |
14352 KB |
Output is correct |
9 |
Correct |
24 ms |
14420 KB |
Output is correct |
10 |
Correct |
26 ms |
14256 KB |
Output is correct |
11 |
Correct |
23 ms |
14160 KB |
Output is correct |
12 |
Correct |
23 ms |
14156 KB |
Output is correct |
13 |
Correct |
23 ms |
14168 KB |
Output is correct |
14 |
Correct |
24 ms |
14256 KB |
Output is correct |
15 |
Correct |
25 ms |
14428 KB |
Output is correct |
16 |
Correct |
20 ms |
11760 KB |
Output is correct |
17 |
Correct |
21 ms |
11932 KB |
Output is correct |
18 |
Correct |
23 ms |
11896 KB |
Output is correct |
19 |
Correct |
21 ms |
11856 KB |
Output is correct |
20 |
Correct |
24 ms |
12464 KB |
Output is correct |
21 |
Correct |
25 ms |
12172 KB |
Output is correct |
22 |
Correct |
23 ms |
14676 KB |
Output is correct |
23 |
Correct |
20 ms |
11912 KB |
Output is correct |
24 |
Correct |
20 ms |
12124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1056 KB |
Output is correct |
2 |
Correct |
0 ms |
784 KB |
Output is correct |
3 |
Correct |
1 ms |
1040 KB |
Output is correct |
4 |
Correct |
0 ms |
1056 KB |
Output is correct |
5 |
Correct |
1 ms |
1056 KB |
Output is correct |
6 |
Correct |
0 ms |
1048 KB |
Output is correct |
7 |
Correct |
1 ms |
1056 KB |
Output is correct |
8 |
Correct |
1 ms |
1056 KB |
Output is correct |
9 |
Correct |
0 ms |
1052 KB |
Output is correct |
10 |
Correct |
2 ms |
1036 KB |
Output is correct |
11 |
Correct |
0 ms |
1056 KB |
Output is correct |
12 |
Correct |
1 ms |
1052 KB |
Output is correct |
13 |
Correct |
1 ms |
1056 KB |
Output is correct |
14 |
Correct |
1 ms |
1140 KB |
Output is correct |
15 |
Correct |
1 ms |
1044 KB |
Output is correct |
16 |
Correct |
0 ms |
1060 KB |
Output is correct |
17 |
Correct |
0 ms |
1048 KB |
Output is correct |
18 |
Correct |
0 ms |
1048 KB |
Output is correct |
19 |
Correct |
1 ms |
1040 KB |
Output is correct |
20 |
Correct |
0 ms |
1056 KB |
Output is correct |
21 |
Correct |
1 ms |
1040 KB |
Output is correct |
22 |
Correct |
1 ms |
1048 KB |
Output is correct |
23 |
Correct |
0 ms |
1060 KB |
Output is correct |
24 |
Correct |
2 ms |
1056 KB |
Output is correct |
25 |
Correct |
1 ms |
1048 KB |
Output is correct |
26 |
Correct |
2 ms |
1056 KB |
Output is correct |
27 |
Correct |
0 ms |
1048 KB |
Output is correct |
28 |
Correct |
0 ms |
1052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
11916 KB |
Output is correct |
2 |
Correct |
24 ms |
12396 KB |
Output is correct |
3 |
Correct |
0 ms |
796 KB |
Output is correct |
4 |
Correct |
16 ms |
11536 KB |
Output is correct |
5 |
Correct |
27 ms |
13148 KB |
Output is correct |
6 |
Correct |
30 ms |
13144 KB |
Output is correct |
7 |
Correct |
23 ms |
12112 KB |
Output is correct |
8 |
Correct |
24 ms |
12124 KB |
Output is correct |
9 |
Correct |
26 ms |
13140 KB |
Output is correct |
10 |
Correct |
28 ms |
13148 KB |
Output is correct |
11 |
Correct |
29 ms |
13144 KB |
Output is correct |
12 |
Correct |
24 ms |
13140 KB |
Output is correct |
13 |
Correct |
23 ms |
13164 KB |
Output is correct |
14 |
Correct |
23 ms |
13156 KB |
Output is correct |
15 |
Correct |
26 ms |
13148 KB |
Output is correct |
16 |
Correct |
25 ms |
13148 KB |
Output is correct |
17 |
Correct |
22 ms |
12840 KB |
Output is correct |
18 |
Correct |
22 ms |
12892 KB |
Output is correct |
19 |
Correct |
25 ms |
12808 KB |
Output is correct |
20 |
Correct |
22 ms |
12892 KB |
Output is correct |
21 |
Correct |
22 ms |
12904 KB |
Output is correct |
22 |
Correct |
22 ms |
12900 KB |
Output is correct |
23 |
Correct |
22 ms |
11892 KB |
Output is correct |
24 |
Correct |
19 ms |
11884 KB |
Output is correct |
25 |
Correct |
24 ms |
12132 KB |
Output is correct |
26 |
Correct |
23 ms |
12132 KB |
Output is correct |
27 |
Correct |
23 ms |
12468 KB |
Output is correct |
28 |
Correct |
22 ms |
12460 KB |
Output is correct |
29 |
Correct |
26 ms |
12556 KB |
Output is correct |
30 |
Correct |
22 ms |
12360 KB |
Output is correct |
31 |
Correct |
19 ms |
11880 KB |
Output is correct |
32 |
Correct |
22 ms |
11876 KB |
Output is correct |
33 |
Correct |
22 ms |
12124 KB |
Output is correct |
34 |
Correct |
25 ms |
12280 KB |
Output is correct |
35 |
Correct |
21 ms |
12376 KB |
Output is correct |
36 |
Correct |
24 ms |
12392 KB |
Output is correct |
37 |
Correct |
23 ms |
12376 KB |
Output is correct |
38 |
Correct |
21 ms |
12384 KB |
Output is correct |
39 |
Correct |
23 ms |
12392 KB |
Output is correct |
40 |
Correct |
22 ms |
12388 KB |
Output is correct |
41 |
Correct |
24 ms |
12624 KB |
Output is correct |
42 |
Correct |
30 ms |
12624 KB |
Output is correct |
43 |
Correct |
24 ms |
12640 KB |
Output is correct |
44 |
Correct |
25 ms |
12636 KB |
Output is correct |
45 |
Correct |
30 ms |
12628 KB |
Output is correct |
46 |
Correct |
24 ms |
12632 KB |
Output is correct |
47 |
Correct |
22 ms |
12448 KB |
Output is correct |
48 |
Correct |
25 ms |
12312 KB |
Output is correct |
49 |
Correct |
20 ms |
12116 KB |
Output is correct |
50 |
Correct |
25 ms |
12376 KB |
Output is correct |
51 |
Correct |
22 ms |
12124 KB |
Output is correct |
52 |
Correct |
20 ms |
12120 KB |
Output is correct |
53 |
Correct |
22 ms |
12080 KB |
Output is correct |
54 |
Correct |
22 ms |
12128 KB |
Output is correct |
55 |
Correct |
20 ms |
12124 KB |
Output is correct |
56 |
Correct |
19 ms |
11976 KB |
Output is correct |
57 |
Correct |
19 ms |
12124 KB |
Output is correct |
58 |
Correct |
22 ms |
12128 KB |
Output is correct |
59 |
Correct |
26 ms |
12304 KB |
Output is correct |
60 |
Correct |
19 ms |
12212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
11872 KB |
Output is correct |
2 |
Correct |
20 ms |
12132 KB |
Output is correct |
3 |
Correct |
1 ms |
792 KB |
Output is correct |
4 |
Correct |
17 ms |
11596 KB |
Output is correct |
5 |
Correct |
32 ms |
13140 KB |
Output is correct |
6 |
Correct |
25 ms |
13140 KB |
Output is correct |
7 |
Correct |
24 ms |
12124 KB |
Output is correct |
8 |
Correct |
20 ms |
12124 KB |
Output is correct |
9 |
Correct |
24 ms |
13136 KB |
Output is correct |
10 |
Correct |
24 ms |
13064 KB |
Output is correct |
11 |
Correct |
24 ms |
13028 KB |
Output is correct |
12 |
Correct |
24 ms |
13148 KB |
Output is correct |
13 |
Correct |
24 ms |
13140 KB |
Output is correct |
14 |
Correct |
24 ms |
13152 KB |
Output is correct |
15 |
Correct |
26 ms |
13076 KB |
Output is correct |
16 |
Correct |
24 ms |
12988 KB |
Output is correct |
17 |
Correct |
23 ms |
12712 KB |
Output is correct |
18 |
Correct |
22 ms |
12888 KB |
Output is correct |
19 |
Correct |
24 ms |
12900 KB |
Output is correct |
20 |
Correct |
28 ms |
12656 KB |
Output is correct |
21 |
Correct |
24 ms |
12892 KB |
Output is correct |
22 |
Correct |
27 ms |
12824 KB |
Output is correct |
23 |
Correct |
22 ms |
11856 KB |
Output is correct |
24 |
Correct |
20 ms |
11864 KB |
Output is correct |
25 |
Correct |
19 ms |
12120 KB |
Output is correct |
26 |
Correct |
19 ms |
12112 KB |
Output is correct |
27 |
Correct |
22 ms |
12220 KB |
Output is correct |
28 |
Correct |
23 ms |
12380 KB |
Output is correct |
29 |
Correct |
21 ms |
12380 KB |
Output is correct |
30 |
Correct |
21 ms |
12384 KB |
Output is correct |
31 |
Correct |
24 ms |
12008 KB |
Output is correct |
32 |
Correct |
20 ms |
11856 KB |
Output is correct |
33 |
Correct |
20 ms |
11952 KB |
Output is correct |
34 |
Correct |
24 ms |
12060 KB |
Output is correct |
35 |
Correct |
22 ms |
12356 KB |
Output is correct |
36 |
Correct |
24 ms |
12392 KB |
Output is correct |
37 |
Correct |
23 ms |
12372 KB |
Output is correct |
38 |
Correct |
23 ms |
12376 KB |
Output is correct |
39 |
Correct |
23 ms |
12372 KB |
Output is correct |
40 |
Correct |
21 ms |
12384 KB |
Output is correct |
41 |
Correct |
27 ms |
12628 KB |
Output is correct |
42 |
Correct |
23 ms |
12636 KB |
Output is correct |
43 |
Correct |
24 ms |
12784 KB |
Output is correct |
44 |
Correct |
26 ms |
12628 KB |
Output is correct |
45 |
Correct |
29 ms |
12556 KB |
Output is correct |
46 |
Correct |
24 ms |
12636 KB |
Output is correct |
47 |
Correct |
22 ms |
12056 KB |
Output is correct |
48 |
Correct |
24 ms |
12356 KB |
Output is correct |
49 |
Correct |
20 ms |
12136 KB |
Output is correct |
50 |
Correct |
21 ms |
12376 KB |
Output is correct |
51 |
Correct |
20 ms |
12124 KB |
Output is correct |
52 |
Correct |
19 ms |
12132 KB |
Output is correct |
53 |
Correct |
21 ms |
12188 KB |
Output is correct |
54 |
Correct |
22 ms |
12268 KB |
Output is correct |
55 |
Correct |
19 ms |
12128 KB |
Output is correct |
56 |
Correct |
20 ms |
12116 KB |
Output is correct |
57 |
Correct |
21 ms |
12124 KB |
Output is correct |
58 |
Correct |
20 ms |
12080 KB |
Output is correct |
59 |
Correct |
22 ms |
12128 KB |
Output is correct |
60 |
Correct |
19 ms |
12032 KB |
Output is correct |