# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
670616 |
2022-12-09T18:41:04 Z |
rainboy |
Stray Cat (JOI20_stray) |
C++17 |
|
47 ms |
16804 KB |
#include "Anthony.h"
#include <cstdlib>
#include <vector>
using namespace std;
typedef vector<int> vi;
namespace A {
int min(int a, int b) { return a < b ? a : b; }
const int N = 20000;
int *ej[N], eo[N], dd[N], qu[N], n;
void init(int n_) {
n = n_;
for (int i = 0; i < n; i++)
ej[i] = (int *) malloc(2 * sizeof *ej[i]);
}
void append(int i, int j) {
int o = eo[i]++;
if (o >= 2 && (o & o - 1) == 0)
ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]);
ej[i][o] = j;
}
void bfs() {
for (int i = 0; i < n; i++)
dd[i] = n;
int cnt = 0;
dd[0] = 0, qu[cnt++] = 0;
for (int h = 0; h < cnt; h++) {
int i = qu[h], d = dd[i] + 1;
for (int o = eo[i]; o--; ) {
int j = ej[i][o];
if (dd[j] > d)
dd[j] = d, qu[cnt++] = j;
}
}
}
}
vi Mark(int n, int m, int a, int b, vi uu, vi vv) {
vi cc(m);
if (a >= 3 && b == 0) {
A::init(n);
for (int h = 0; h < m; h++)
A::append(uu[h], vv[h]), A::append(vv[h], uu[h]);
A::bfs();
for (int h = 0; h < m; h++)
cc[h] = A::min(A::dd[uu[h]], A::dd[vv[h]]) % 3;
} else {
}
return cc;
}
#include "Catherine.h"
#include <vector>
using namespace std;
typedef vector<int> vi;
namespace {
int c_;
}
void Init(int a, int b) {
a = b = a;
c_ = -1;
}
int Move(vi kk) {
int a = kk.size();
if (a >= 3) {
if (c_ != -1)
kk[c_]++;
for (int c = 0; c < 3; c++)
if (kk[(c + 2) % 3] == 0 && kk[c] != 0)
return c;
} else
return -1;
return -1;
}
Compilation message
Anthony.cpp: In function 'void A::append(int, int)':
Anthony.cpp:23:24: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
23 | if (o >= 2 && (o & o - 1) == 0)
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
15172 KB |
Output is correct |
2 |
Correct |
0 ms |
512 KB |
Output is correct |
3 |
Correct |
28 ms |
14948 KB |
Output is correct |
4 |
Correct |
47 ms |
16668 KB |
Output is correct |
5 |
Correct |
41 ms |
16804 KB |
Output is correct |
6 |
Correct |
33 ms |
15396 KB |
Output is correct |
7 |
Correct |
32 ms |
15308 KB |
Output is correct |
8 |
Correct |
38 ms |
16032 KB |
Output is correct |
9 |
Correct |
40 ms |
16188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
15172 KB |
Output is correct |
2 |
Correct |
0 ms |
512 KB |
Output is correct |
3 |
Correct |
28 ms |
14948 KB |
Output is correct |
4 |
Correct |
47 ms |
16668 KB |
Output is correct |
5 |
Correct |
41 ms |
16804 KB |
Output is correct |
6 |
Correct |
33 ms |
15396 KB |
Output is correct |
7 |
Correct |
32 ms |
15308 KB |
Output is correct |
8 |
Correct |
38 ms |
16032 KB |
Output is correct |
9 |
Correct |
40 ms |
16188 KB |
Output is correct |
10 |
Correct |
30 ms |
13408 KB |
Output is correct |
11 |
Correct |
34 ms |
13380 KB |
Output is correct |
12 |
Correct |
38 ms |
13548 KB |
Output is correct |
13 |
Correct |
30 ms |
13440 KB |
Output is correct |
14 |
Correct |
35 ms |
13640 KB |
Output is correct |
15 |
Correct |
35 ms |
14100 KB |
Output is correct |
16 |
Correct |
37 ms |
16300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
12764 KB |
Output is correct |
2 |
Correct |
0 ms |
508 KB |
Output is correct |
3 |
Correct |
27 ms |
12340 KB |
Output is correct |
4 |
Correct |
41 ms |
14092 KB |
Output is correct |
5 |
Correct |
43 ms |
14048 KB |
Output is correct |
6 |
Correct |
31 ms |
12772 KB |
Output is correct |
7 |
Correct |
32 ms |
12752 KB |
Output is correct |
8 |
Correct |
37 ms |
13368 KB |
Output is correct |
9 |
Correct |
37 ms |
13364 KB |
Output is correct |
10 |
Correct |
35 ms |
13168 KB |
Output is correct |
11 |
Correct |
34 ms |
13128 KB |
Output is correct |
12 |
Correct |
33 ms |
13220 KB |
Output is correct |
13 |
Correct |
34 ms |
13132 KB |
Output is correct |
14 |
Correct |
37 ms |
13412 KB |
Output is correct |
15 |
Correct |
40 ms |
13428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
12764 KB |
Output is correct |
2 |
Correct |
0 ms |
508 KB |
Output is correct |
3 |
Correct |
27 ms |
12340 KB |
Output is correct |
4 |
Correct |
41 ms |
14092 KB |
Output is correct |
5 |
Correct |
43 ms |
14048 KB |
Output is correct |
6 |
Correct |
31 ms |
12772 KB |
Output is correct |
7 |
Correct |
32 ms |
12752 KB |
Output is correct |
8 |
Correct |
37 ms |
13368 KB |
Output is correct |
9 |
Correct |
37 ms |
13364 KB |
Output is correct |
10 |
Correct |
35 ms |
13168 KB |
Output is correct |
11 |
Correct |
34 ms |
13128 KB |
Output is correct |
12 |
Correct |
33 ms |
13220 KB |
Output is correct |
13 |
Correct |
34 ms |
13132 KB |
Output is correct |
14 |
Correct |
37 ms |
13412 KB |
Output is correct |
15 |
Correct |
40 ms |
13428 KB |
Output is correct |
16 |
Correct |
27 ms |
11236 KB |
Output is correct |
17 |
Correct |
26 ms |
11240 KB |
Output is correct |
18 |
Correct |
28 ms |
11236 KB |
Output is correct |
19 |
Correct |
28 ms |
11224 KB |
Output is correct |
20 |
Correct |
34 ms |
11640 KB |
Output is correct |
21 |
Correct |
31 ms |
11492 KB |
Output is correct |
22 |
Correct |
43 ms |
13636 KB |
Output is correct |
23 |
Correct |
30 ms |
11228 KB |
Output is correct |
24 |
Correct |
28 ms |
11252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
780 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
9468 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
9420 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |