#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 3e5+50;
const ll oo = 1e18;
const ll mod = 1e9+7;
int n;
vector<int> ans;
void add(int l,int r){
if(l > r)return;
int md = (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<md;i++){
s[i] = '1';
add_element(s);
s[i] = '0';
}
add(l,md);
add(md,r);
}
void ask (int l, int r, string no) {
if (l + 1 == r) {
for (int i = 0; i < n; ++i) {
if (no[i] == '0') {
ans[i] = l;
break;
}
}
return;
}
string x = no, y = "";
for (int i = 0; i < n; ++i) {
y += '1';
}
for (int i = 0; i < n; ++i) {
if (no[i] == '0') {
no[i] = '1';
if (check_element(no)) {
x[i] = '1';
y[i] = '0';
}
no[i] = '0';
}
}
int m = l + r >> 1;
ask(l, m, y);
ask(m, r, x);
}
vector<int> restore_permutation(int N, int w, int r) {
int n = N;
add(0,n);
compile_set();
ans.resize(n);
string a = "";
for(int i=0;i<n;i++)a += '0';
ask(0,n,a);
return ans;
}
Compilation message
messy.cpp: In function 'void ask(int, int, std::__cxx11::string)':
messy.cpp:54:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m = l + r >> 1;
~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |