#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];
assert(dep[u] != dep[v]);
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 |
22 ms |
15744 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
24 ms |
15424 KB |
Output is correct |
4 |
Correct |
29 ms |
17244 KB |
Output is correct |
5 |
Correct |
27 ms |
17348 KB |
Output is correct |
6 |
Correct |
26 ms |
16012 KB |
Output is correct |
7 |
Correct |
22 ms |
15956 KB |
Output is correct |
8 |
Correct |
24 ms |
16960 KB |
Output is correct |
9 |
Correct |
24 ms |
16724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
15744 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
24 ms |
15424 KB |
Output is correct |
4 |
Correct |
29 ms |
17244 KB |
Output is correct |
5 |
Correct |
27 ms |
17348 KB |
Output is correct |
6 |
Correct |
26 ms |
16012 KB |
Output is correct |
7 |
Correct |
22 ms |
15956 KB |
Output is correct |
8 |
Correct |
24 ms |
16960 KB |
Output is correct |
9 |
Correct |
24 ms |
16724 KB |
Output is correct |
10 |
Runtime error |
5 ms |
3672 KB |
Execution killed with signal 6 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
13180 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
19 ms |
13112 KB |
Output is correct |
4 |
Correct |
24 ms |
15076 KB |
Output is correct |
5 |
Correct |
31 ms |
15192 KB |
Output is correct |
6 |
Correct |
21 ms |
13672 KB |
Output is correct |
7 |
Correct |
21 ms |
13656 KB |
Output is correct |
8 |
Correct |
28 ms |
14428 KB |
Output is correct |
9 |
Correct |
23 ms |
14420 KB |
Output is correct |
10 |
Correct |
24 ms |
14168 KB |
Output is correct |
11 |
Correct |
22 ms |
14164 KB |
Output is correct |
12 |
Correct |
22 ms |
14164 KB |
Output is correct |
13 |
Correct |
26 ms |
14180 KB |
Output is correct |
14 |
Correct |
28 ms |
14412 KB |
Output is correct |
15 |
Correct |
23 ms |
14420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
13180 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
19 ms |
13112 KB |
Output is correct |
4 |
Correct |
24 ms |
15076 KB |
Output is correct |
5 |
Correct |
31 ms |
15192 KB |
Output is correct |
6 |
Correct |
21 ms |
13672 KB |
Output is correct |
7 |
Correct |
21 ms |
13656 KB |
Output is correct |
8 |
Correct |
28 ms |
14428 KB |
Output is correct |
9 |
Correct |
23 ms |
14420 KB |
Output is correct |
10 |
Correct |
24 ms |
14168 KB |
Output is correct |
11 |
Correct |
22 ms |
14164 KB |
Output is correct |
12 |
Correct |
22 ms |
14164 KB |
Output is correct |
13 |
Correct |
26 ms |
14180 KB |
Output is correct |
14 |
Correct |
28 ms |
14412 KB |
Output is correct |
15 |
Correct |
23 ms |
14420 KB |
Output is correct |
16 |
Runtime error |
5 ms |
3932 KB |
Execution killed with signal 6 |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1044 KB |
Output is correct |
2 |
Correct |
0 ms |
796 KB |
Output is correct |
3 |
Correct |
0 ms |
1048 KB |
Output is correct |
4 |
Correct |
1 ms |
1056 KB |
Output is correct |
5 |
Correct |
0 ms |
1048 KB |
Output is correct |
6 |
Correct |
1 ms |
1048 KB |
Output is correct |
7 |
Incorrect |
0 ms |
1052 KB |
Wrong Answer [5] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
11396 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
11392 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |