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;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);++i)
#define PB push_back
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
int n;
vector<int> ans;
void madd(string s,int x){
FOR(i,0,n){
if(i&(1<<x)&&s[i]=='0'){
s[i]='1';
add_element(s);
s[i]='0';
}
}
if(x<=0)return;
string s2=s;
FOR(i,0,n){
if(i&(1<<x)){
s2[i]='1';
}else{
s[i]='1';
}
}
madd(s,x-1);
madd(s2,x-1);
}
void chk(string s,int x){
bool je[128];
FOR(i,0,n){
if(s[i]=='0'){
s[i]='1';
je[i]=check_element(s);
s[i]='0';
}else{
je[i]=false;
}
}
string s2=s;
FOR(i,0,n){
if(je[i]){
s2[i]='1';
ans[i]+=(1<<x);
}else{
s[i]='1';
}
}
if(x>0){
chk(s,x-1);
chk(s2,x-1);
}
}
vector<int> restore_permutation(int _n, int w, int r) {
n=_n;
ans.resize(n);
int b=1;
while(n!=(1<<b))++b;
madd(string(n,'0'),b-1);
compile_set();
chk(string(n,'0'),b-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... |