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;
#ifdef DEBUG
#include "/home/ioi/contests/ioi16d2/debug.h"
#else
#define debug(...) void(37)
#endif
#include "messy.h"
std::vector<int> restore_permutation(int N, int w, int r) {
/*
add_element("0");
compile_set();
check_element("0");
return std::vector<int>();
*/
{
vector<vector<int>> sets;
sets.emplace_back();
for (int i = 0; i < N; ++i) sets[0].push_back(i);
for (int l = N; l > 1; l >>= 1) {
for (int j = 0; j * l < N; ++j) {
for (int i = j * l + l / 2; i < (j + 1) * l; ++i) {
string ask(N, '1');
for (int k = j * l; k < (j + 1) * l; ++k) ask[k] = '0';
ask[i] = '1';
add_element(ask);
}
}
}
}
debug("added");
compile_set();
vector<int> ans(N);
{
vector<vector<int>> sets;
sets.emplace_back();
for (int i = 0; i < N; ++i) sets[0].push_back(i);
for (int l = N; l > 1; l >>= 1) {
vector<vector<int>> next;
for (int j = 0; j * l < N; ++j) {
array<vector<int>, 2> lr;
for (auto x : sets[j]) {
string ask(N, '1');
for (auto y : sets[j]) ask[y] = '0';
ask[x] = '1';
lr[check_element(ask)].push_back(x);
}
next.push_back(lr[0]);
next.push_back(lr[1]);
}
swap(next, sets);
}
for (int i = 0; i < N; ++i) ans[sets[i][0]] = 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... |