# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
780113 |
2023-07-12T06:43:04 Z |
ymm |
Stray Cat (JOI20_stray) |
C++17 |
|
45 ms |
17084 KB |
#include "Anthony.h"
#include <bits/stdc++.h>
#define Loop(x, l, r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;
namespace {
const int N = 20'010;
vector<int> A[N];
int dis[N];
void bfs() {
memset(dis, -1, sizeof(dis));
vector<int> q = {0};
dis[0] = 0;
Loop (i,0,q.size()) {
int v = q[i];
for (int u : A[v]) {
if (dis[u] == -1) {
dis[u] = dis[v]+1;
q.push_back(u);
}
}
}
}
int height[N];
int val[N];
const int pat[] = {0, 0, 1, 0, 1, 1};
const int pats = sizeof(pat)/sizeof(*pat);
void dfs(int v, int p, int x, int h) {
height[v] = h;
val[v] = pat[x%pats];
for (int u : A[v]) {
if (u == p)
continue;
if (A[v].size() == 2)
dfs(u, v, x+1, h+1);
else
dfs(u, v, val[v]==0? 2: 0, h+1);
}
}
} // namespace
std::vector<int> Mark(int N, int M, int a, int b,
std::vector<int> U, std::vector<int> V) {
Loop (i,0,M) {
int v = V[i], u = U[i];
A[v].push_back(u);
A[u].push_back(v);
}
vector<int> ans(M);
if (a == 2) {
dfs(0, -1, 0, 0);
Loop (i,0,M) {
int v = V[i], u = U[i];
if (height[v] > height[u])
swap(v, u);
ans[i] = val[u];
}
} else {
bfs();
Loop (i,0,M) {
int v = V[i], u = U[i];
ans[i] = min(dis[v], dis[u]) % 3;
}
}
return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define Loop(x, l, r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;
namespace {
int (*move_ptr)(vector<int>);
int lst = -1;
int move3(vector<int> y) {
if (y[0] && y[1])
return 0;
if (y[1] && y[2])
return 1;
if (y[2] && y[0])
return 2;
return !!y[1] + 2*!!y[2];
}
int move_up(vector<int> y) {
if (!!y[0] + !!y[1] == 1)
return !!y[1];
if (y[0] + (lst == 0) == 1)
return 0;
else
return 1;
}
const int pat[] = {0, 0, 1, 0, 1, 1};
const int pats = sizeof(pat)/sizeof(*pat);
vector<int> cur_pat;
bool test() {
vector<int> p(pat, pat+pats), q(cur_pat);
Loop (_,0,pats) {
int x = p.back();
p.pop_back();
if (p == q)
return 0;
p.insert(p.begin(), x);
}
return 1;
}
int move_test(vector<int> y) {
if (y[0] + y[1] + (lst != -1) != 2)
return (move_ptr = move_up)(y);
if (cur_pat.size() == 0) {
if (y[0] && y[1]) {
cur_pat = {0, 1};
return 1;
}
if (y[0]) {
cur_pat = {0, 0};
return 0;
} else {
cur_pat = {1, 1};
return 1;
}
}
cur_pat.push_back(!!y[1]);
if (cur_pat.size() == 5) {
move_ptr = move_up;
if (test())
return move_up(y);
else
return -1;
}
return !!y[1];
}
} // namespace
void Init(int A, int B) {
move_ptr = A == 2? move_test: move3;
}
int Move(std::vector<int> y) {
int x = move_ptr(y);
lst = x;
return x;
}
Compilation message
Anthony.cpp: In function 'void {anonymous}::bfs()':
Anthony.cpp:3:42: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
3 | #define Loop(x, l, r) for (ll x = (l); x < (r); ++x)
| ^
Anthony.cpp:16:3: note: in expansion of macro 'Loop'
16 | Loop (i,0,q.size()) {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
15840 KB |
Output is correct |
2 |
Correct |
1 ms |
1156 KB |
Output is correct |
3 |
Correct |
23 ms |
15176 KB |
Output is correct |
4 |
Correct |
34 ms |
16984 KB |
Output is correct |
5 |
Correct |
36 ms |
17084 KB |
Output is correct |
6 |
Correct |
28 ms |
15576 KB |
Output is correct |
7 |
Correct |
32 ms |
15628 KB |
Output is correct |
8 |
Correct |
45 ms |
16388 KB |
Output is correct |
9 |
Correct |
33 ms |
16504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
15840 KB |
Output is correct |
2 |
Correct |
1 ms |
1156 KB |
Output is correct |
3 |
Correct |
23 ms |
15176 KB |
Output is correct |
4 |
Correct |
34 ms |
16984 KB |
Output is correct |
5 |
Correct |
36 ms |
17084 KB |
Output is correct |
6 |
Correct |
28 ms |
15576 KB |
Output is correct |
7 |
Correct |
32 ms |
15628 KB |
Output is correct |
8 |
Correct |
45 ms |
16388 KB |
Output is correct |
9 |
Correct |
33 ms |
16504 KB |
Output is correct |
10 |
Correct |
24 ms |
13864 KB |
Output is correct |
11 |
Correct |
34 ms |
13680 KB |
Output is correct |
12 |
Correct |
26 ms |
13760 KB |
Output is correct |
13 |
Correct |
25 ms |
13844 KB |
Output is correct |
14 |
Correct |
26 ms |
13996 KB |
Output is correct |
15 |
Correct |
28 ms |
14340 KB |
Output is correct |
16 |
Correct |
33 ms |
16504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
13548 KB |
Output is correct |
2 |
Correct |
2 ms |
1164 KB |
Output is correct |
3 |
Correct |
27 ms |
12956 KB |
Output is correct |
4 |
Correct |
33 ms |
14816 KB |
Output is correct |
5 |
Correct |
34 ms |
14812 KB |
Output is correct |
6 |
Correct |
26 ms |
13428 KB |
Output is correct |
7 |
Correct |
31 ms |
13516 KB |
Output is correct |
8 |
Correct |
32 ms |
14152 KB |
Output is correct |
9 |
Correct |
31 ms |
14144 KB |
Output is correct |
10 |
Correct |
33 ms |
13792 KB |
Output is correct |
11 |
Correct |
27 ms |
13884 KB |
Output is correct |
12 |
Correct |
38 ms |
13920 KB |
Output is correct |
13 |
Correct |
40 ms |
13908 KB |
Output is correct |
14 |
Correct |
32 ms |
14248 KB |
Output is correct |
15 |
Correct |
33 ms |
14180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
13548 KB |
Output is correct |
2 |
Correct |
2 ms |
1164 KB |
Output is correct |
3 |
Correct |
27 ms |
12956 KB |
Output is correct |
4 |
Correct |
33 ms |
14816 KB |
Output is correct |
5 |
Correct |
34 ms |
14812 KB |
Output is correct |
6 |
Correct |
26 ms |
13428 KB |
Output is correct |
7 |
Correct |
31 ms |
13516 KB |
Output is correct |
8 |
Correct |
32 ms |
14152 KB |
Output is correct |
9 |
Correct |
31 ms |
14144 KB |
Output is correct |
10 |
Correct |
33 ms |
13792 KB |
Output is correct |
11 |
Correct |
27 ms |
13884 KB |
Output is correct |
12 |
Correct |
38 ms |
13920 KB |
Output is correct |
13 |
Correct |
40 ms |
13908 KB |
Output is correct |
14 |
Correct |
32 ms |
14248 KB |
Output is correct |
15 |
Correct |
33 ms |
14180 KB |
Output is correct |
16 |
Correct |
23 ms |
11900 KB |
Output is correct |
17 |
Correct |
24 ms |
11928 KB |
Output is correct |
18 |
Correct |
32 ms |
11864 KB |
Output is correct |
19 |
Correct |
24 ms |
11976 KB |
Output is correct |
20 |
Correct |
26 ms |
12524 KB |
Output is correct |
21 |
Correct |
33 ms |
12308 KB |
Output is correct |
22 |
Correct |
29 ms |
14440 KB |
Output is correct |
23 |
Correct |
25 ms |
12040 KB |
Output is correct |
24 |
Correct |
31 ms |
11992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1292 KB |
Output is correct |
2 |
Correct |
1 ms |
1028 KB |
Output is correct |
3 |
Correct |
2 ms |
1344 KB |
Output is correct |
4 |
Correct |
2 ms |
1496 KB |
Output is correct |
5 |
Correct |
2 ms |
1288 KB |
Output is correct |
6 |
Incorrect |
2 ms |
1288 KB |
Wrong Answer [5] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
11600 KB |
Output is correct |
2 |
Incorrect |
25 ms |
12560 KB |
Wrong Answer [5] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
11552 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |