#include "Anthony.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define trav(x, a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define pb push_back
using namespace std;
namespace {
const int N = 2e4 + 5;
vi adj[N];
int dp[N];
string bl = "001011";
}
vi Mark(int N, int M, int A, int B, vi U, vi V) {
for (int i = 0; i < M; i++)
adj[U[i]].pb(i), adj[V[i]].pb(i);
vi X(M);
if (A > 2) {
deque<int> pq;
pq.pb(0);
fill(dp, dp+N, N+1);
dp[0] = 0;
for (int i = 0; i < M; i++)
X[i] = 2;
while (!pq.empty()) {
int u = pq.front(); pq.pop_front();
trav(x, adj[u]) {
int v = U[x]^V[x]^u;
if (dp[v] > dp[u] + 1) {
dp[v] = dp[u] + 1;
pq.pb(v);
}
if (dp[v] == dp[u] + 1 || dp[v] == dp[u]) {
X[x] = dp[u]%3;
}
}
}
return X;
}
function<void(int,int,int,int)> dfs = [&](int u, int p, int d, int l) {
int f = (u != 0 && sz(adj[u]) > 2 ? 1 : 0);
if (f) d = l ? 2 : 0;
trav(x, adj[u]) {
int v = U[x]^V[x]^u;
if (v != p) {
X[x] = bl[d%sz(bl)]-'0';
dfs(v, u, d+1, X[x]^1);
}
}
};
dfs(0, -1, 0, 0);
return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define sz(x) (int)(x).size()
#define pb push_back
using namespace std;
int A, B;
void Init(int A, int B) {
::A = A;
::B = B;
}
namespace {
int lst = -1;
bool fnd = 0;
string bl = "001011001011";
string rbl = "110100110100";
string cur = "";
}
int Move(vi y) {
if (A > 2) {
if (~lst) y[lst]++;
if (y[0] && y[1])
return lst = 0;
if (y[0] && y[2])
return lst = 2;
if (y[1] && y[2])
return lst = 1;
for (int i = 0; i < 3; i++)
if (y[i])
return lst = i;
}
if (fnd) {
if (y[0]+y[1] > 1)
y[lst]++;
return lst = (y[0]==1 ? 0 : 1);
}
if (lst == -1) {
if (y[0]+y[1] == 1) {
fnd = 1;
return lst = (y[0]==1 ? 0 : 1);
}
if (y[0]+y[1] > 2) {
fnd = 1;
return lst = (y[0]==1 ? 0 : 1);
}
lst = (y[0]>0 ? 0 : 1);
y[lst]--;
cur.pb((char)('0'+(y[0]>0 ? 0 : 1)));
cur.pb((char)('0'+lst));
return lst;
}
if (y[0]+y[1]==0) {
fnd = 1;
return -1;
}
if (y[0]+y[1]>1) {
fnd = 1;
y[lst]++;
if (y[lst] == 1)
return -1;
return lst = lst^1;
}
cur.pb((y[0] == 1 ? '0' : '1'));
vector<int> pos;
for (int i = 0; i < 6; i++) {
bool fl = 1;
for (int j = 0; fl && j < sz(cur); j++)
fl &= cur[j] == bl[i+j];
if (fl)
pos.pb(i);
fl = 1;
for (int j = 0; fl && j < sz(cur); j++)
fl &= cur[j] == rbl[i+j];
if (fl)
pos.pb(~i);
}
if (sz(pos) == 1) {
fnd = 1;
return pos[0] >= 0 ? -1 : (lst = (y[0]==1 ? 0 : 1));
}
lst = (y[0]==1 ? 0 : 1);
cur.pb((char)('0'+lst));
return lst;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
15980 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
46 ms |
15304 KB |
Output is correct |
4 |
Correct |
64 ms |
16980 KB |
Output is correct |
5 |
Correct |
68 ms |
17132 KB |
Output is correct |
6 |
Correct |
54 ms |
15696 KB |
Output is correct |
7 |
Correct |
54 ms |
15956 KB |
Output is correct |
8 |
Correct |
61 ms |
16728 KB |
Output is correct |
9 |
Correct |
61 ms |
16480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
15980 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
46 ms |
15304 KB |
Output is correct |
4 |
Correct |
64 ms |
16980 KB |
Output is correct |
5 |
Correct |
68 ms |
17132 KB |
Output is correct |
6 |
Correct |
54 ms |
15696 KB |
Output is correct |
7 |
Correct |
54 ms |
15956 KB |
Output is correct |
8 |
Correct |
61 ms |
16728 KB |
Output is correct |
9 |
Correct |
61 ms |
16480 KB |
Output is correct |
10 |
Correct |
50 ms |
13888 KB |
Output is correct |
11 |
Correct |
50 ms |
13896 KB |
Output is correct |
12 |
Correct |
53 ms |
13780 KB |
Output is correct |
13 |
Correct |
50 ms |
14000 KB |
Output is correct |
14 |
Correct |
51 ms |
14028 KB |
Output is correct |
15 |
Correct |
56 ms |
14408 KB |
Output is correct |
16 |
Correct |
70 ms |
16716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
13776 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
45 ms |
13168 KB |
Output is correct |
4 |
Correct |
62 ms |
14932 KB |
Output is correct |
5 |
Correct |
63 ms |
14932 KB |
Output is correct |
6 |
Correct |
51 ms |
13652 KB |
Output is correct |
7 |
Correct |
51 ms |
13520 KB |
Output is correct |
8 |
Correct |
57 ms |
14312 KB |
Output is correct |
9 |
Correct |
62 ms |
14476 KB |
Output is correct |
10 |
Correct |
55 ms |
14060 KB |
Output is correct |
11 |
Correct |
55 ms |
14048 KB |
Output is correct |
12 |
Correct |
55 ms |
14056 KB |
Output is correct |
13 |
Correct |
55 ms |
14060 KB |
Output is correct |
14 |
Correct |
59 ms |
14320 KB |
Output is correct |
15 |
Correct |
57 ms |
14320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
13776 KB |
Output is correct |
2 |
Correct |
9 ms |
1536 KB |
Output is correct |
3 |
Correct |
45 ms |
13168 KB |
Output is correct |
4 |
Correct |
62 ms |
14932 KB |
Output is correct |
5 |
Correct |
63 ms |
14932 KB |
Output is correct |
6 |
Correct |
51 ms |
13652 KB |
Output is correct |
7 |
Correct |
51 ms |
13520 KB |
Output is correct |
8 |
Correct |
57 ms |
14312 KB |
Output is correct |
9 |
Correct |
62 ms |
14476 KB |
Output is correct |
10 |
Correct |
55 ms |
14060 KB |
Output is correct |
11 |
Correct |
55 ms |
14048 KB |
Output is correct |
12 |
Correct |
55 ms |
14056 KB |
Output is correct |
13 |
Correct |
55 ms |
14060 KB |
Output is correct |
14 |
Correct |
59 ms |
14320 KB |
Output is correct |
15 |
Correct |
57 ms |
14320 KB |
Output is correct |
16 |
Correct |
46 ms |
12000 KB |
Output is correct |
17 |
Correct |
48 ms |
12232 KB |
Output is correct |
18 |
Correct |
48 ms |
12096 KB |
Output is correct |
19 |
Correct |
57 ms |
11980 KB |
Output is correct |
20 |
Correct |
55 ms |
12612 KB |
Output is correct |
21 |
Correct |
60 ms |
12456 KB |
Output is correct |
22 |
Correct |
57 ms |
14672 KB |
Output is correct |
23 |
Correct |
51 ms |
12204 KB |
Output is correct |
24 |
Correct |
52 ms |
12220 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
1792 KB |
Output is correct |
2 |
Correct |
11 ms |
1536 KB |
Output is correct |
3 |
Correct |
10 ms |
1536 KB |
Output is correct |
4 |
Correct |
12 ms |
1792 KB |
Output is correct |
5 |
Correct |
10 ms |
1792 KB |
Output is correct |
6 |
Correct |
10 ms |
1792 KB |
Output is correct |
7 |
Correct |
10 ms |
1792 KB |
Output is correct |
8 |
Incorrect |
10 ms |
1792 KB |
Wrong Answer [5] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
51 ms |
11468 KB |
Output is correct |
2 |
Correct |
60 ms |
13024 KB |
Output is correct |
3 |
Correct |
9 ms |
1536 KB |
Output is correct |
4 |
Correct |
55 ms |
11432 KB |
Output is correct |
5 |
Correct |
62 ms |
14816 KB |
Output is correct |
6 |
Incorrect |
49 ms |
13652 KB |
Wrong Answer [5] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
11600 KB |
Output is correct |
2 |
Correct |
54 ms |
12844 KB |
Output is correct |
3 |
Correct |
9 ms |
1536 KB |
Output is correct |
4 |
Correct |
56 ms |
11316 KB |
Output is correct |
5 |
Correct |
71 ms |
14640 KB |
Output is correct |
6 |
Incorrect |
56 ms |
13916 KB |
Wrong Answer [5] |
7 |
Halted |
0 ms |
0 KB |
- |