#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 {
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) {
if (up) {
return lst = find(y.begin(), y.end(), 1) - y.begin();
}
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) {
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;
return lst = find(g.begin(), g.end(), 1) - g.begin();
}
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:8:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
8 | void __print() {
| ^~~~~~~
Catherine.cpp:8:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
8 | void __print() {
| ^~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
15932 KB |
Output is correct |
2 |
Correct |
1 ms |
868 KB |
Output is correct |
3 |
Correct |
20 ms |
15400 KB |
Output is correct |
4 |
Correct |
31 ms |
17168 KB |
Output is correct |
5 |
Correct |
26 ms |
17244 KB |
Output is correct |
6 |
Correct |
22 ms |
15956 KB |
Output is correct |
7 |
Correct |
24 ms |
16040 KB |
Output is correct |
8 |
Correct |
24 ms |
16664 KB |
Output is correct |
9 |
Correct |
27 ms |
16672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
15932 KB |
Output is correct |
2 |
Correct |
1 ms |
868 KB |
Output is correct |
3 |
Correct |
20 ms |
15400 KB |
Output is correct |
4 |
Correct |
31 ms |
17168 KB |
Output is correct |
5 |
Correct |
26 ms |
17244 KB |
Output is correct |
6 |
Correct |
22 ms |
15956 KB |
Output is correct |
7 |
Correct |
24 ms |
16040 KB |
Output is correct |
8 |
Correct |
24 ms |
16664 KB |
Output is correct |
9 |
Correct |
27 ms |
16672 KB |
Output is correct |
10 |
Correct |
24 ms |
13896 KB |
Output is correct |
11 |
Correct |
22 ms |
13904 KB |
Output is correct |
12 |
Correct |
21 ms |
13900 KB |
Output is correct |
13 |
Correct |
23 ms |
13896 KB |
Output is correct |
14 |
Correct |
23 ms |
14100 KB |
Output is correct |
15 |
Correct |
28 ms |
14388 KB |
Output is correct |
16 |
Correct |
31 ms |
16728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
13632 KB |
Output is correct |
2 |
Correct |
0 ms |
780 KB |
Output is correct |
3 |
Correct |
26 ms |
13284 KB |
Output is correct |
4 |
Correct |
27 ms |
15192 KB |
Output is correct |
5 |
Correct |
27 ms |
15196 KB |
Output is correct |
6 |
Correct |
23 ms |
13580 KB |
Output is correct |
7 |
Correct |
22 ms |
13640 KB |
Output is correct |
8 |
Correct |
28 ms |
14444 KB |
Output is correct |
9 |
Correct |
28 ms |
14476 KB |
Output is correct |
10 |
Correct |
25 ms |
14104 KB |
Output is correct |
11 |
Correct |
28 ms |
14024 KB |
Output is correct |
12 |
Correct |
30 ms |
14032 KB |
Output is correct |
13 |
Correct |
23 ms |
14156 KB |
Output is correct |
14 |
Correct |
40 ms |
14404 KB |
Output is correct |
15 |
Correct |
26 ms |
14440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
13632 KB |
Output is correct |
2 |
Correct |
0 ms |
780 KB |
Output is correct |
3 |
Correct |
26 ms |
13284 KB |
Output is correct |
4 |
Correct |
27 ms |
15192 KB |
Output is correct |
5 |
Correct |
27 ms |
15196 KB |
Output is correct |
6 |
Correct |
23 ms |
13580 KB |
Output is correct |
7 |
Correct |
22 ms |
13640 KB |
Output is correct |
8 |
Correct |
28 ms |
14444 KB |
Output is correct |
9 |
Correct |
28 ms |
14476 KB |
Output is correct |
10 |
Correct |
25 ms |
14104 KB |
Output is correct |
11 |
Correct |
28 ms |
14024 KB |
Output is correct |
12 |
Correct |
30 ms |
14032 KB |
Output is correct |
13 |
Correct |
23 ms |
14156 KB |
Output is correct |
14 |
Correct |
40 ms |
14404 KB |
Output is correct |
15 |
Correct |
26 ms |
14440 KB |
Output is correct |
16 |
Correct |
24 ms |
11944 KB |
Output is correct |
17 |
Correct |
22 ms |
11968 KB |
Output is correct |
18 |
Correct |
21 ms |
12048 KB |
Output is correct |
19 |
Correct |
26 ms |
11860 KB |
Output is correct |
20 |
Correct |
28 ms |
12468 KB |
Output is correct |
21 |
Correct |
21 ms |
12392 KB |
Output is correct |
22 |
Correct |
28 ms |
14528 KB |
Output is correct |
23 |
Correct |
20 ms |
12104 KB |
Output is correct |
24 |
Correct |
31 ms |
12108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1040 KB |
Output is correct |
2 |
Correct |
0 ms |
784 KB |
Output is correct |
3 |
Correct |
1 ms |
1048 KB |
Output is correct |
4 |
Correct |
0 ms |
1056 KB |
Output is correct |
5 |
Correct |
1 ms |
1056 KB |
Output is correct |
6 |
Correct |
2 ms |
1056 KB |
Output is correct |
7 |
Incorrect |
1 ms |
1056 KB |
Wrong Answer [5] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
11868 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
11860 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |