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/stdc++.h>
using namespace std;
const int BASE = 3;
const int POWER = 8; // 3 ** 8 = 6561
vector<vector<int>> devise_strategy(int n) {
vector<vector<int>> ans;
vector<vector<int>> digits(n);
for (int i = 0; i < n; i++)
{
for (int j = 0, x = i; j < POWER; j++)
{
digits[i].push_back(x % BASE);
x /= BASE;
}
reverse(begin(digits[i]), end(digits[i]));
}
{
vector<int> a = {0};
for (int j = 0; j < n; j++)
a.push_back(digits[j][0] + 1);
ans.push_back(a);
}
for (int i = 0; i < POWER; i++)
for (int x = 0; x < BASE; x++)
{
int otherBag = i % 2, curBag = otherBag ^ 1;
vector<int> a = {curBag};
for (int j = 0; j < n; j++)
if (digits[j][i] < x) a.push_back(-curBag - 1);
else if (digits[j][i] > x) a.push_back(-otherBag - 1);
else a.push_back((i + 1) * BASE + digits[j][i + 1] + 1);
ans.push_back(a);
}
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... |