#include<bits/stdc++.h>
#include "messy.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
vector<int>restore_permutation(int n,int w,int r){
vector<pair<int,int>>vec;
vec.pb({0,n-1});
while(vec.size()<n){
vector<pair<int,int>>u;
string s(n,'1');
for(auto [l,r]:vec){
int mid=(l+r)/2;
for(int i=l;i<=r;i++){
s[i]='0';
}
for(int i=mid+1;i<=r;i++){
s[i]='1';
add_element(s);
s[i]='0';
}
for(int i=l;i<=r;i++){
s[i]='1';
}
u.pb({l,mid});
u.pb({mid+1,r});
}
vec=u;
}
compile_set();
string s(n,'0');
vector<vector<int>>v,nxt;
vector<int>u,a,b;
for(int i=0;i<n;i++){
u.pb(i);
}
v.pb(u);
vector<int>p(n,0);
int add=n;
while(v.size()<n){
add/=2;
nxt.clear();
string t(n,'1');
for(auto u:v){
a.clear();
b.clear();
for(int i:u) t[i]='0';
for(int i:u){
t[i]='1';
if(check_element(t)){
p[i]+=add;
a.pb(i);
}
else{
b.pb(i);
}
t[i]='0';
}
for(int i:u) t[i]='1';
nxt.pb(a);
nxt.pb(b);
}
v=nxt;
}
return p;
}
Compilation message
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:16:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
16 | while(vec.size()<n){
| ~~~~~~~~~~^~
messy.cpp:47:19: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
47 | while(v.size()<n){
| ~~~~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
n = 8 |
2 |
Correct |
1 ms |
348 KB |
n = 8 |
3 |
Correct |
0 ms |
432 KB |
n = 8 |
4 |
Correct |
1 ms |
344 KB |
n = 8 |
5 |
Correct |
0 ms |
344 KB |
n = 8 |
6 |
Correct |
0 ms |
348 KB |
n = 8 |
7 |
Correct |
1 ms |
348 KB |
n = 8 |
8 |
Correct |
1 ms |
348 KB |
n = 8 |
9 |
Correct |
0 ms |
348 KB |
n = 8 |
10 |
Correct |
1 ms |
344 KB |
n = 8 |
11 |
Correct |
0 ms |
348 KB |
n = 8 |
12 |
Correct |
0 ms |
348 KB |
n = 8 |
13 |
Correct |
1 ms |
348 KB |
n = 8 |
14 |
Correct |
0 ms |
348 KB |
n = 8 |
15 |
Correct |
1 ms |
436 KB |
n = 8 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
n = 32 |
2 |
Correct |
1 ms |
344 KB |
n = 32 |
3 |
Correct |
1 ms |
348 KB |
n = 32 |
4 |
Correct |
0 ms |
356 KB |
n = 32 |
5 |
Correct |
1 ms |
348 KB |
n = 32 |
6 |
Correct |
0 ms |
464 KB |
n = 32 |
7 |
Correct |
1 ms |
348 KB |
n = 32 |
8 |
Correct |
1 ms |
348 KB |
n = 32 |
9 |
Correct |
1 ms |
348 KB |
n = 32 |
10 |
Correct |
1 ms |
436 KB |
n = 32 |
11 |
Correct |
1 ms |
348 KB |
n = 32 |
12 |
Correct |
1 ms |
348 KB |
n = 32 |
13 |
Correct |
0 ms |
436 KB |
n = 32 |
14 |
Correct |
1 ms |
348 KB |
n = 32 |
15 |
Correct |
1 ms |
348 KB |
n = 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 32 |
2 |
Correct |
1 ms |
348 KB |
n = 32 |
3 |
Correct |
0 ms |
348 KB |
n = 32 |
4 |
Correct |
1 ms |
344 KB |
n = 32 |
5 |
Correct |
0 ms |
348 KB |
n = 32 |
6 |
Correct |
1 ms |
348 KB |
n = 32 |
7 |
Correct |
1 ms |
348 KB |
n = 32 |
8 |
Correct |
0 ms |
440 KB |
n = 32 |
9 |
Correct |
1 ms |
348 KB |
n = 32 |
10 |
Correct |
0 ms |
348 KB |
n = 32 |
11 |
Correct |
0 ms |
348 KB |
n = 32 |
12 |
Correct |
1 ms |
344 KB |
n = 32 |
13 |
Correct |
1 ms |
344 KB |
n = 32 |
14 |
Correct |
0 ms |
348 KB |
n = 32 |
15 |
Correct |
1 ms |
432 KB |
n = 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
n = 128 |
2 |
Correct |
1 ms |
600 KB |
n = 128 |
3 |
Correct |
1 ms |
600 KB |
n = 128 |
4 |
Correct |
1 ms |
600 KB |
n = 128 |
5 |
Correct |
1 ms |
604 KB |
n = 128 |
6 |
Correct |
1 ms |
600 KB |
n = 128 |
7 |
Correct |
1 ms |
608 KB |
n = 128 |
8 |
Correct |
1 ms |
604 KB |
n = 128 |
9 |
Correct |
1 ms |
600 KB |
n = 128 |
10 |
Correct |
1 ms |
600 KB |
n = 128 |
11 |
Correct |
1 ms |
600 KB |
n = 128 |
12 |
Correct |
2 ms |
600 KB |
n = 128 |
13 |
Correct |
1 ms |
604 KB |
n = 128 |
14 |
Correct |
1 ms |
604 KB |
n = 128 |
15 |
Correct |
1 ms |
604 KB |
n = 128 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
604 KB |
n = 128 |
2 |
Correct |
1 ms |
600 KB |
n = 128 |
3 |
Correct |
1 ms |
604 KB |
n = 128 |
4 |
Correct |
1 ms |
604 KB |
n = 128 |
5 |
Correct |
1 ms |
600 KB |
n = 128 |
6 |
Correct |
2 ms |
608 KB |
n = 128 |
7 |
Correct |
2 ms |
604 KB |
n = 128 |
8 |
Correct |
1 ms |
608 KB |
n = 128 |
9 |
Correct |
1 ms |
600 KB |
n = 128 |
10 |
Correct |
1 ms |
612 KB |
n = 128 |
11 |
Correct |
1 ms |
604 KB |
n = 128 |
12 |
Correct |
1 ms |
436 KB |
n = 128 |
13 |
Correct |
1 ms |
608 KB |
n = 128 |
14 |
Correct |
1 ms |
600 KB |
n = 128 |
15 |
Correct |
1 ms |
436 KB |
n = 128 |