#include <bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
using namespace std;
#include "messy.h"
vector<ll>P;
ll nn;
void ask(ll l , ll r){
if(l == r)return;
string s = "";
for(int i=0; i<nn; i++)
s += '0';
for(int i=0; i<nn; i++)
if(i < l || i > r)
s[i] = '1';
for(int i=l; i <= (l + r) / 2; i++){
s[i] = '1';
add_element(s);
s[i] = '0';
}
ask(l , (l + r) / 2);
ask((l + r) / 2 + 1 , r);
}
void solve(vector<ll>x , vector<ll>y){
if(x.size() == 1){
P[y[0]] = x[0];
return;
}
string s = "";
for(int i=0; i<nn; i++)
s += '1';
for(int i=0; i<y.size(); i++)
s[y[i]] = '0';
vector<ll>v1 , v2 , x1 , x2;
for(int i=0; i<y.size(); i++){
s[y[i]] = '1';
if(check_element(s)){
//cout << y[i] << '\n';
v1.pb(y[i]);
}
else v2.pb(y[i]);
s[y[i]] = '0';
}
for(int i=0; i<x.size(); i++)
if(i < (int)x.size() / 2)
x1.pb(x[i]);
else
x2.pb(x[i]);
solve(x1 , v1);
solve(x2 , v2);
}
vector<int> restore_permutation(int N, int w, int r){
nn = N;
string s = "";
vector<ll>v1 , v2;
for(int i=0; i<nn; i++){
v1.pb(i);
v2.pb(i);
}
ask(0 , nn - 1);
for(int i=0; i<nn; i++)
P.pb(0);
compile_set();
solve(v1 , v2);
return P;
}
Compilation message
messy.cpp: In function 'void solve(std::vector<int>, std::vector<int>)':
messy.cpp:34:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<y.size(); i++)
~^~~~~~~~~
messy.cpp:37:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<y.size(); i++){
~^~~~~~~~~
messy.cpp:46:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<x.size(); i++)
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
n = 8 |
2 |
Correct |
5 ms |
256 KB |
n = 8 |
3 |
Correct |
5 ms |
384 KB |
n = 8 |
4 |
Correct |
5 ms |
384 KB |
n = 8 |
5 |
Correct |
5 ms |
256 KB |
n = 8 |
6 |
Correct |
5 ms |
384 KB |
n = 8 |
7 |
Correct |
4 ms |
384 KB |
n = 8 |
8 |
Correct |
5 ms |
384 KB |
n = 8 |
9 |
Correct |
5 ms |
384 KB |
n = 8 |
10 |
Correct |
5 ms |
256 KB |
n = 8 |
11 |
Correct |
5 ms |
384 KB |
n = 8 |
12 |
Correct |
5 ms |
256 KB |
n = 8 |
13 |
Correct |
5 ms |
384 KB |
n = 8 |
14 |
Correct |
5 ms |
256 KB |
n = 8 |
15 |
Correct |
5 ms |
256 KB |
n = 8 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
n = 32 |
2 |
Correct |
5 ms |
384 KB |
n = 32 |
3 |
Correct |
5 ms |
384 KB |
n = 32 |
4 |
Correct |
5 ms |
384 KB |
n = 32 |
5 |
Correct |
5 ms |
384 KB |
n = 32 |
6 |
Correct |
5 ms |
384 KB |
n = 32 |
7 |
Correct |
5 ms |
384 KB |
n = 32 |
8 |
Correct |
5 ms |
384 KB |
n = 32 |
9 |
Correct |
5 ms |
384 KB |
n = 32 |
10 |
Correct |
5 ms |
384 KB |
n = 32 |
11 |
Correct |
5 ms |
384 KB |
n = 32 |
12 |
Correct |
5 ms |
384 KB |
n = 32 |
13 |
Correct |
5 ms |
384 KB |
n = 32 |
14 |
Correct |
5 ms |
384 KB |
n = 32 |
15 |
Correct |
5 ms |
384 KB |
n = 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
n = 32 |
2 |
Correct |
5 ms |
384 KB |
n = 32 |
3 |
Correct |
5 ms |
384 KB |
n = 32 |
4 |
Correct |
5 ms |
384 KB |
n = 32 |
5 |
Correct |
5 ms |
384 KB |
n = 32 |
6 |
Correct |
5 ms |
384 KB |
n = 32 |
7 |
Correct |
5 ms |
384 KB |
n = 32 |
8 |
Correct |
5 ms |
384 KB |
n = 32 |
9 |
Correct |
5 ms |
384 KB |
n = 32 |
10 |
Correct |
5 ms |
384 KB |
n = 32 |
11 |
Correct |
5 ms |
384 KB |
n = 32 |
12 |
Correct |
5 ms |
384 KB |
n = 32 |
13 |
Correct |
5 ms |
384 KB |
n = 32 |
14 |
Correct |
5 ms |
384 KB |
n = 32 |
15 |
Correct |
5 ms |
384 KB |
n = 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
512 KB |
n = 128 |
2 |
Correct |
7 ms |
512 KB |
n = 128 |
3 |
Correct |
6 ms |
512 KB |
n = 128 |
4 |
Correct |
7 ms |
512 KB |
n = 128 |
5 |
Correct |
6 ms |
512 KB |
n = 128 |
6 |
Correct |
7 ms |
512 KB |
n = 128 |
7 |
Correct |
6 ms |
512 KB |
n = 128 |
8 |
Correct |
7 ms |
512 KB |
n = 128 |
9 |
Correct |
7 ms |
512 KB |
n = 128 |
10 |
Correct |
6 ms |
512 KB |
n = 128 |
11 |
Correct |
6 ms |
512 KB |
n = 128 |
12 |
Correct |
7 ms |
512 KB |
n = 128 |
13 |
Correct |
6 ms |
512 KB |
n = 128 |
14 |
Correct |
6 ms |
512 KB |
n = 128 |
15 |
Correct |
6 ms |
512 KB |
n = 128 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
512 KB |
n = 128 |
2 |
Correct |
6 ms |
512 KB |
n = 128 |
3 |
Correct |
7 ms |
512 KB |
n = 128 |
4 |
Correct |
6 ms |
512 KB |
n = 128 |
5 |
Correct |
6 ms |
512 KB |
n = 128 |
6 |
Correct |
6 ms |
512 KB |
n = 128 |
7 |
Correct |
6 ms |
512 KB |
n = 128 |
8 |
Correct |
6 ms |
512 KB |
n = 128 |
9 |
Correct |
6 ms |
512 KB |
n = 128 |
10 |
Correct |
6 ms |
512 KB |
n = 128 |
11 |
Correct |
6 ms |
512 KB |
n = 128 |
12 |
Correct |
6 ms |
512 KB |
n = 128 |
13 |
Correct |
6 ms |
512 KB |
n = 128 |
14 |
Correct |
6 ms |
512 KB |
n = 128 |
15 |
Correct |
6 ms |
512 KB |
n = 128 |