This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/extc++.h"
using namespace std;
template <typename T>
void dbgh(const T& t) {
cerr << t << endl;
}
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t << " | ";
dbgh(u...);
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
<< ": "; \
dbgh(__VA_ARGS__)
#else
#define cerr \
if (false) \
cerr
#define dbg(...)
#endif
#define endl "\n"
#define long int64_t
#define sz(x) int(size(x))
const int bases[] = {2, 2, 3, 3, 3, 3, 3, 1};
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> digits;
digits.push_back({-2, 0, 0, -1});
for (int i : bases) {
vector<vector<int>> nxt;
auto push_one = [&](int x) -> void {
vector<int> cur {x};
cur.resize(sz(digits[0]) + 1, x);
nxt.push_back(cur);
};
push_one(-2);
for (int j = 0; j < i; j++) {
auto cur = digits;
for (auto& a : cur) {
a.insert(a.begin(), j);
}
nxt.insert(nxt.end(), begin(cur), end(cur));
}
push_one(-1);
digits = nxt;
}
vector<vector<int>> ans;
int bag = 0;
auto go = [&](int base, int i) -> void {
int offset = sz(ans) + base;
int me = -1 - bag, other = -3 - me;
vector<int> cans;
cans.push_back(bag);
for (auto& a : digits) {
int cur = a[i];
if (cur >= 0) {
cans.push_back(offset + cur);
} else {
if (cur == -2) {
cans.push_back(me);
} else {
cans.push_back(other);
}
}
}
bag ^= 1;
for (int j = 0; j < base; j++) {
ans.push_back(cans);
}
};
for (int i = 0; i < sz(bases); i++) {
go(bases[sz(bases) - i - 1], i);
}
go(1, sz(bases));
{
int me = -1 - bag, other = -3 - me;
vector<int> cans;
cans.push_back(bag);
int used = 0;
for (int j = 0; j < sz(digits); j++) {
if (digits[j].back() >= 0) {
if (used % 2 == 0) {
cans.push_back(me);
} else {
cans.push_back(other);
}
used++;
} else {
cans.push_back(0);
}
}
ans.push_back(cans);
}
for (auto& a : ans) {
a.resize(n + 1);
}
dbg(ans[0][2]);
dbg(sz(ans));
for (auto& a : ans) {
for (auto& b : a) {
cerr << b << " ";
}
cerr << endl;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |