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>
#include "messy.h"
using namespace std;
string base = "";
std::vector<int> restore_permutation(int n, int w, int r) {
int P = 0;
while(1<<P < n) P++;
//cerr << P << "\n";
for (int i = 0; i < n; i++) base += "0";
for (int v = 0; v < n; v++)
{
for (int p = 0; p < P; p++)
{
if ((v&(1<<p)) == 0)
{
string query = base;
for (int i = (v>>(p+1))<<(p+1); (i>>(p+1)) == (v>>(p+1)); i++) if (i != v)
{
query[i] = '1';
}
add_element(query);
//cerr << query << "\n";
}
}
}
compile_set();
vector < set < int > > ranges(n);
for (int i = 0; i < n; i++) ranges[0].insert(i);
for (int p = P-1; p >= 0; p--)
{
for (int i = 0; i < n; i += (1<<(p+1)))
{
set < int > zeros;
set < int > ones = ranges[i];
string s = base;
for (auto v : ranges[i])
{
s[v] = '1';
}
for (auto v : ranges[i])
{
s[v] = '0';
//cerr << "check " << s << "\n";
if (check_element(s))
{
//cerr << "ok\n";
zeros.insert(v);
ones.erase(v);
}
s[v] = '1';
}
ranges[i] = zeros;
ranges[i+(1<<p)] = ones;
}
}
vector < int > ans(n);
for (int i = 0; i < n; i++)
{
assert(ranges[i].size() == 1);
ans[*ranges[i].begin()] = 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... |