# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139861 | farhad13 | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 9 ms | 760 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"
#define pb push_back
using namespace std;
vector<int> restore_permutation(int n, int w, int r) {
vector<int> vec;
vec.assign(n,-1);
map<string,int> m;
string x(n,'0');
string y(n,'0');
for(int i=0;i<n-1;i++)
{y[i]='1';
add_element(y);
m[y]=1;
}
compile_set();
int cnt[129];
vector<int> asd;
for(int i=0;i<n;i++)cnt[i]=1;
for(int j=0;j<n;j++){
for(int i=0;i<n;i++)
{
if(x[i]=='1')continue;
x[i]='1';
bool p=check_element(x);
if(!m[x] && p)asd.pb(j),asd.pb(i);
x[i]='0';
if(!m[x] && p)vec[j]=i;
}
if(vec[j]!=-1)x[vec[j]]='1',cnt[vec[j]]=0;
else if(n<=8)x[j]='1',vec[j]=j,cnt[vec[j]]=0;
}
int h,d=0;
for(int i=0;i<n;i++)if(cnt[i])h=i;
for(int i=0;i<n;i++)if(vec[i]==-1)vec[i]=h,d++;
if(d>1)
for(int i=0;i<n;i++)
vec[i]=i;
if(asd.size()==2)
vec[asd[0]]=asd[1],vec[asd[1]]=asd[0];
vector<int> ans(n);
for(int i=0;i<n;i++)
{ans[vec[i]]=i;}
//for(int i=0;i<n;i++)cout<<ans[i]<<" ";
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... |