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<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 2e2 + 20;
int res[maxn];
void solve1(int n , int l , int r)
{
int m = (r - l);
string x = string(l , '1') , y = string(n - r , '1');
if(m == 2)
{
add_element(x + "10" + y);
return;
}
m = (l + r) / 2;
for(int i = l; i < m; i++)
{
string tmp = x + string(r - l , '0') + y;
tmp[i] = '1';
add_element(tmp);
}
solve1(n , l , m);
solve1(n , m , r);
}
bool check(string tmp , int k)
{
tmp[k] = '1';
bool f = check_element(tmp);
return f;
}
void solve2(int n , int l , int r , vector<int> candid)
{
string tmp = string(n , '1');
for(auto x : candid)
tmp[x] = '0';
assert((int)candid.size() == r - l);
if(r - l == 2)
{
if(!check(tmp , candid[0]))
swap(candid[0] , candid[1]);
res[l] = candid[0];
res[l + 1] = candid[1];
return;
}
vector<int> x , y;
for(int i = 0; i < r - l; i++)
{
if(check(tmp , candid[i]))
x.pb(candid[i]);
else
y.pb(candid[i]);
}
int m = (l + r) / 2;
solve2(n , l , m , x);
solve2(n , m , r , y);
}
vector<int> restore_permutation(int n, int w, int r)
{
solve1(n , 0 , n);
compile_set();
vector<int> candid;
for(int i = 0; i < n; i++)
candid.pb(i);
solve2(n , 0 , n , candid);
for(int i = 0; i < n; i++)
candid[res[i]] = i;
return candid;
}
# | 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... |