# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1026782 | boyliguanhan | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 2 ms | 604 KiB |
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 <vector>
using namespace std;
#include "messy.h"
vector<int>ans;
int n_;
void write(int l,int r){
if(l==r)return;
string str(n_,'1');
for(int i=l;i<=r;i++)
str[i]='0';
for(int i=l;i<=l+r>>1;i++){
str[i]='1';
add_element(str);
str[i]='0';
}
write(l,l+r>>1);
write(l+r+2>>1,r);
}
void read(int l,int r,vector<int>pos){
if(l==r)return void(ans[pos[0]]=l);
string str(n_,'1');
for(auto i:pos)
str[i]='0';
vector<int>posl,posr;
for(auto i:pos){
str[i]='1';
if(check_element(str))
posl.push_back(i);
else posr.push_back(i);
str[i]='0';
}
read(l,l+r>>1,posl);
read(l+r+2>>1,r,posr);
}
vector<int> restore_permutation(int n, int w, int r) {
n_=n;
ans.resize(n);
write(0,n-1);
compile_set();
vector<int>v2(n);
for(int i=0;i<n;i++)
v2[i]=i;
read(0,n-1,v2);
return ans;
}
Compilation message (stderr)
# | 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... |