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 <vector>
#include <iostream>
#include "messy.h"
#include <set>
using namespace std;
void add(int l, int r, string s)
{
if (l + 1 == r) return;
for (int i = l; i < (l + r)/2; i++)
{
string t = s;
t[i] = '1';
add_element(t);
}
string s1 = s;
for (int i = l; i < (l + r)/2; i++)
{
s1[i] = '1';
}
add((l + r)/2, r, s1);
s1 = s;
for (int i = (l + r)/2; i < r; i++)
{
s1[i] = '1';
}
add(l, (l + r)/2, s1);
}
void check(int l, int r, set<int> nr, vector<int> &res, string st)
{
if (nr.size() == 1)
{
for (int i : nr) res[i] = l;
return;
}
set<int> in;
set<int> out;
for (int i : nr)
{
string ot = st;
ot[i] = '1';
if (check_element(ot))
{
in.insert(i);
}
else
{
out.insert(i);
}
}
string s1 = st;
for (int i : out)
{
s1[i] = '1';
}
check(l, (l + r)/2, in, res, s1);
s1 = st;
for (int i : in)
{
s1[i] = '1';
}
check((l + r)/2, r, out, res, s1);
}
vector<int> restore_permutation(int n, int w, int r) {
add(0, n, string(n, '0'));
compile_set();
set<int> rs;
for (int i = 0; i < n; i++)
{
rs.insert(i);
}
vector<int> res(n, -1);
check(0, n, rs, res, string(n, '0'));
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... |