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>
#define pb push_back
#define vi vector<int>
#include "messy.h"
using namespace std;
int T[8];
string f(int x){
string s(8,'0');
for(int i=7;i>=0;i--){
if((1<<i)&x)s[i]='1';
}
return s;
}
vector<int> restore_permutation(int n, int w, int r) {
//add_element("0");
//compile_set();
//check_element("0");
for(int i=1;i<=8;i++){
string s(8,'0');
for(int l=0;l<i;l++){
s[n-1-l]='1';
}
add_element(s);
}
compile_set();
for(int i=1;i<(1<<n);i++){
string curr=f(i);
bool ok=check_element(curr);
if(ok){
for(int l=0;l<8;l++){
if(curr[l]=='1')T[l+1]++;
}
}
}
vi res;
for(int i=0;i<n;i++)res.pb(i);
int a=0,b=0;
for(int i=1;i<=n;i++){
if(T[i]!=i){
if(a==0){
a=i-1;
}else{
b=i-1;
}
}
}
swap(res[a],res[b]);
return res;
}
/*
8 256 256
0 1 2 3 4 5 7 6
8 256 256
0 1 4 3 2 5 6 7
*/
# | 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... |