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 "messy.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
bool ask(string &s, int i) {
s[i] = '1';
bool b = check_element(s);
s[i] = '0';
return b;
}
void add(string &s, int i) { s[i] = '1'; add_element(s); s[i] = '0'; }
vector<int> restore_permutation(int n, int _, int __) {
for (int sz = n; sz != 1; sz >>= 1) {
for (int l = 0; l != n; l += sz) {
string s(n, '1');
rep(i, l, l + sz) s[i] = '0';
rep(i, l, l + sz / 2) add(s, i);
}
}
compile_set();
vector<int> p(n); iota(all(p), 0);
for (int sz = n; sz != 1; sz >>= 1) {
vector<bool> v(n);
for (int l = 0; l != n; l += sz) {
string s(n, '1');
rep(i, l, l + sz) s[p[i]] = '0';
rep(i, l, l + sz) v[p[i]] = ask(s, p[i]);
partition(begin(p) + l, begin(p) + l + sz, [&v](int x) { return v[x]; });
}
}
vector<int> res(n);
rep(i, 0, n) res[p[i]] = i;
return res;
}
# | 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... |