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;
int cnt = 0;
void gen(int n, int l, int r){
if(l > r || l == r) return;
string s;
for(int i = 0; i < n; i++){
s += '1';
}
int m = (l + r) / 2;
for(int i = l; i <= r; i++){
s[i] = '0';
}
for(int i = l; i <= m; i++){
s[i] = '1';
cnt++;
//cerr<<s<<endl;
add_element(s);
s[i] = '0';
}
gen(n, l, m);
gen(n, m + 1, r);
}
vector<int> ans;
void solve(int n, int l, int r, vector<int> ind){
string s;
if(l == r){
ans[ind[0]] = l;
return;
}
for(int i = 0; i < n; i++){
s += "1";
}
int m = (l + r) / 2;
for(int i = 0; i < ind.size(); i++)
s[ind[i]] = '0';
vector<int> a, b;
for(int i = 0; i < ind.size(); i++){
s[ind[i]] = '1';
if(check_element(s)){
a.push_back(ind[i]);
}else{
b.push_back(ind[i]);
}
s[ind[i]] = '0';
}
assert(a.size() == ind.size() / 2);
assert(b.size() == ind.size() / 2);
solve(n, l, m, a);
solve(n, m + 1, r, b);
}
vector<int> restore_permutation(int n, int w, int r) {
ans.resize(n, 0);
gen(n, 0, n - 1);
compile_set();
vector<int> cur;
for(int i = 0; i < n; i++){
cur.push_back(i);
}
solve(n, 0, n - 1, cur);
return ans;
}
Compilation message (stderr)
messy.cpp: In function 'void solve(int, int, int, std::vector<int>)':
messy.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0; i < ind.size(); i++)
| ~~^~~~~~~~~~~~
messy.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i = 0; i < ind.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... |