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"
#define fi first
#define se second
using namespace std;
string s;
vector<int> ans;
inline void swp(int x)
{
s[x]=(s[x]=='0' ? '1':'0');
return;
}
void add(int r,int m,int n)
{
if(m==n)
return;
int i;
for(i=r+m;i<n;i+=2*m)
{
swp(i);
add_element(s);
swp(i);
}
for(i=r+m;i<n;i+=2*m)
swp(i);
add(r,2*m,n);
for(i=r;i<n;i+=m)
swp(i);
add(r+m,2*m,n);
for(i=r;i<n;i+=2*m)
swp(i);
return;
}
void check(vector<int> av,int w,int p)
{
if(av.size()==1)
{
ans[av[0]]=w;
return;
}
vector<int> tmp[2];
for(auto v:av)
{
swp(v);
tmp[check_element(s)].push_back(v);
swp(v);
}
for(auto v:tmp[1])
swp(v);
check(tmp[0],w,2*p);
for(auto v:av)
swp(v);
check(tmp[1],w+p,2*p);
for(auto v:tmp[0])
swp(v);
return;
}
vector<int> restore_permutation(int n,int w,int r)
{
s=string(n,'0');
ans.resize(n);
add(0,1,n);
compile_set();
vector<int> tmp(n);
for(int i=0;i<n;i++)
tmp[i]=i;
check(tmp,0,1);
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... |