# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123240 | baqargam | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 4 ms | 508 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<bits/stdc++.h>
#include "messy.h"
using namespace std;
string base;
vector<int>res;
void ddc(int l,int r){
//cout<<l<<" "<<r<<endl;
string s=base;
int mid=(l+r)/2;
for(int i=l;i<r;i++){
s[i]='0';
}
for(int i=l;i<mid;i++){
s[i]='1';
// cout<<s<<endl;
add_element(s);
s[i]='0';
}
if(r-l==1)return;
ddc(l,mid);
ddc(mid,r);
}
void fnd(int l,int r,vector<int> g){
if(r-l==1) {res[g[0]]=l;return;}
vector<int>g1,g2;
string s=base;
int mid=(l+r)/2;
//cout<<l<<" "<<r<<" "<<g.size()<<endl;
for(int i=0;i<g.size();i++){
// cout<<g[i]<<" ";
s[g[i]]='0';
}
//cout<<endl;
for(int i=0;i<g.size();i++){
s[g[i]]='1';
int ch=check_element(s);
// cout<<"? "<<s<<" "<<g[i]<<" "<<ch<<endl;
if(ch)
g1.push_back(g[i]);
else
g2.push_back(g[i]);
s[g[i]]='0';
}
fnd(l,mid,g1);
fnd(mid,r,g2);
}
vector<int> restore_permutation(int n, int w, int r) {
string s="";
vector<int>g;
int l=log2(n);
int gn=1;
for(int i=0;i<n;i++){
base+='1';
g.push_back(i);
res.push_back(i);
}
ddc(0,n);
compile_set();
fnd(0,n,g);
return res;
}
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... |