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;
#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 (stderr)
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){
| ~~~~~~~~^~
# | 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... |