This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// https://www2.ioi-jp.org/camp/2020/2020-sp-tasks/day3/stray-review.pdf
#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 {
template<class T>
ostream &operator << (ostream &os, vector<T> v) {
for (int i = 0; i < v.size(); ++i) {
os << (i ? ", " : "{") << v[i];
}
return os << "}";
}
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) {
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) {
if (up) {
return lst = find(y.begin(), y.end(), 1) - y.begin();
}
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;
int nxt = find(g.begin(), g.end(), 1) - g.begin();
return lst == nxt ? -1 : lst = nxt;
}
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 (stderr)
Anthony.cpp:10:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
10 | void __print() {
| ^~~~~~~
Catherine.cpp:16:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
16 | void __print() {
| ^~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |