#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
#define pb(x) push_back(x)
vector<int> ans;
int n;
void put(int l , int r){
if(l == r - 1)return;
int m = (l + r)/2;
string s = "";
for(int i = 0; i < n; i++){
s += '1';
}
for(int i = l; i < r; i++){
s[i] = '0';
}
for(int i = l; i < m; i++){
s[i] = '1';
cout << s << '\n';
add_element(s);
s[i] = '0';
}
add_element(s);
put(l , m);
put(m , r);
}
void solve(vector<int>& v , int l , int r){
//cout << l << ' ' << r << ' ' << v.size() << endl;
if(l == r - 1){
ans[l] = v[0];
return;
}
int m = (l + r)/2;
string s = "";
for(int i = 0; i < n; i++)s += '1';
for(int i = 0; i < v.size(); i++){
s[v[i]] = '0';
}
vector<int> a , b;
for(int i = 0; i < v.size(); i++){
s[v[i]] = '1';
//cout << s << ' ';
if(check_element(s)){
//cout << v[i] << ' ';
a.pb(v[i]);
}
else b.pb(v[i]);
s[v[i]] = '0';
}
//cout << '\n';
//assert(a.size() == b.size());
solve(a , l , m);
solve(b,m,r);
}
vector<int> restore_permutation(int nn, int w, int r){
n = nn;
ans.resize(n);
put(0 , n);
compile_set();
vector<int> cur;
for(int i = 0; i < n; i++){
cur.pb(i);
}
solve(cur , 0 , n);
//cout << "came" << endl;
/*for(int i = 0; i < n; i++){
cout << ans[i] << endl;
}*/
return ans;
}
Compilation message
messy.cpp: In function 'void solve(std::vector<int>&, int, int)':
messy.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int i = 0; i < v.size(); i++){
| ~~^~~~~~~~~~
messy.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i = 0; i < v.size(); i++){
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong secret! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Wrong secret! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong secret! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
Wrong secret! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
Wrong secret! |
2 |
Halted |
0 ms |
0 KB |
- |