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;
int pe[130],pi[130];
std::vector<int> restore_permutation(int n, int w, int r)
{
string sn;
for(int i=0;i<n;i++) sn+='0';
int logn=0;
while((1<<logn)!=n) logn++;
for(int i=logn-1;i>=0;i--)
{
for(int j=0;j<n;j++) if(((1<<i)|j)==j)
{
string s=sn;
for(int x=0;x<n;x++)
{
if(x==j)
{
s[x]++;
continue;
}
for(int k=i+1;k<logn;k++) if(((1<<k)&x)!=((1<<k)&j))
{
s[x]++;
break;
}
}
add_element(s);
}
}
compile_set();
for(int i=logn-1;i>=0;i--)
{
for(int j=0;j<n;j++)
{
string s=sn;
for(int x=0;x<n;x++)
{
if(x==j)
{
s[x]++;
continue;
}
for(int k=i+1;k<logn;k++) if(((1<<k)&pi[x])!=((1<<k)&pi[j]))
{
s[x]++;
break;
}
}
if(check_element(s)) pi[j]+=(1<<i);
}
}
vector<int> sol;
for(int i=0;i<n;i++) sol.push_back(pi[i]);
return sol;
}
# | 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... |