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>
using namespace std;
#define for2(a,b,c) for(int a=b;a<c;a++)
#include "messy.h"
int n;
string get(int i,int j){
string res;
for2(i,0,n) res += "0";
res[i] = res[j] = '1';
return res;
}
vector<int> restore_permutation(int N, int w, int r) {
n = N;
string s;
for2(i,0,n) s += "0";
for2(i,0,7){
s[i] = '1';
add_element(s);
}
for2(j,0,7) for2(i,7,n)if(i&(1<<j)) add_element(get(j,i));
compile_set();
vector<int> p(n,-1);
vector<int> rnd(n);
srand(10);
for2(i,0,n) rnd[i] = i;
for2(i,0,n) s[i] = '0';
int X[7];
for2(i,0,7){
random_shuffle(rnd.begin(),rnd.end());
for(auto x : rnd) if(s[x] != '1'){
s[x] = '1';
if(check_element(s)){
p[x] = i;
X[i] = x;
break;
}
s[x] = '0';
}
}
for2(i,0,7){
for2(j,7,n) if(check_element(get(X[i],j))){
p[j] |= (1<<i);
}
}
return p;
}
# | 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... |