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;
#include "messy.h"
string st(vector<int> s){
string a;
for(auto i: s) a+=(char)('0'+i);
return a;
}
void add(vector<int> s){
add_element(st(s));
}
int check(vector<int> s){
return check_element(st(s));
}
std::vector<int> restore_permutation(int n, int w, int r) {
vector<int> s(n);
s[0]=1;
add(s);
for(int i=1; i<n; i++){
s[i]=1;
add(s);
/*s[i-1]=0;
for(int l=i+1; l<n; l++){
s[l]=1;
add(s);
s[l] = 0;
}
s[i-1] = 1;*/
}
compile_set();
for(auto &i: s) i=0;
vector<int> ans(n, -1);
vector<int> t(n);
for(int l=0; l<n; l++){
s=t;
for(int i=0; i<n; i++){
if(s[i]==1) continue;
s[i]=1;
if(check(s)){
ans[i]=l;
t[i]=1;
break;
}
s[i]=0;
}
}
for(int i=0; i<n; i++) if(ans[i]==-1) ans[i]=-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... |