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;
//#include "grader.cpp"
int N;
vector <int> res;
void add (int l , int r){
if(l==r)
return;
string s;
for(int i = 0 ; i < N; i++)
s=s+'1';
for(int i = l ; i <= r ;i++)
s[i]='0';
int mid = (l+r)/2;
for( int i = l ; i <= mid; i++){
s[i]='1';
add_element(s);
s[i]='0';
}
add(l, mid);
add(mid+1, r);
}
void check(int l, int r, vector <int> vec){
if(l==r){
res[vec[0]] = l;
return ;
}
string s;
vector <int> left, right;
for(int i = 0 ; i < N; i++)
s=s+'1';
for(int i = 0 ; i <vec.size() ;i++)
s[vec[i]]='0';
int mid = (l + r) / 2;
for(int i = l ; i <= r; i++){
s[vec[i-l]]='1';
if(check_element(s)){
left.push_back(vec[i-l]);
}
else
right.push_back(vec[i-l]);
s[vec[i-l]]='0';
}
check(l, mid,left);
check( mid+1, r, right);
}
vector <int> restore_permutation(int n, int w, int r) {
N = n;
add(0, n-1);
compile_set();
vector <int > vec;
vec.resize(n);
res.resize(n);
for(int i = 0 ; i < n; i++)
vec[i] = i;
check( 0, n-1, vec);
return res;
}
Compilation message (stderr)
messy.cpp: In function 'void check(int, int, std::vector<int>)':
messy.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i = 0 ; i <vec.size() ;i++)
| ~~^~~~~~~~~~~
# | 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... |