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 dbg(...)
#define cerr \
if (false) \
cerr
#endif
#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())
void add_element(string x);
bool check_element(string x);
void compile_set();
vector<int> restore_permutation(int n, int, int) {
for (int i = 0; i < 8; i++) {
string s(n, '1');
s[i] = '0';
add_element(s);
}
int acnts[8] {};
for (int i = 7; i >= 0; i--) {
if (i & 1) {
for (int j = i + 1; j < 8; j++) {
acnts[i]++;
acnts[j]++;
string s(n, '1');
s[i] = s[j] = '0';
add_element(s);
}
}
}
assert(acnts[6] == acnts[7]);
for (int i = 0; i < 7; i++) {
for (int j = 6; j < n; j++) {
if ((j >> i) & 1) {
string s(n, '0');
s[j] = '1';
for (int k = 0; k < i; k++) {
s[k] = '1';
}
add_element(s);
}
}
}
compile_set();
vector<int> cands;
for (int i = 0; i < n; i++) {
string s(n, '1');
s[i] = '0';
if (check_element(s)) {
cands.push_back(i);
}
}
assert(sz(cands) == 8);
int cnts[8] {};
for (int i = 0; i < 8; i++) {
for (int j = 0; j < i; j++) {
string s(n, '1');
s[cands[i]] = s[cands[j]] = '0';
if (check_element(s)) {
cnts[i]++;
cnts[j]++;
}
}
}
for (int i = 0; i < 8; i++) {
cerr << cnts[i] << " \n"[i == 7];
}
for (int i = 0; i < 8; i++) {
cerr << acnts[i] << " \n"[i == 7];
}
int arr[6];
bool vis[n] {};
vector<int> ans(n);
for (int i = 0; i < 6; i++) {
arr[i] = cands[find(begin(cnts), end(cnts), acnts[i]) - cnts];
vis[arr[i]] = true;
ans[arr[i]] = i;
dbg(i, arr[i]);
}
for (int i = 0; i < 7; i++) {
for (int j = 0; j < n; j++) {
if (vis[j]) {
continue;
}
string s(n, '0');
for (int k = 0; k < i; k++) {
s[arr[k]] = '1';
}
s[j] = '1';
if (check_element(s)) {
ans[j] |= 1 << i;
}
}
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |