# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
690944 | NemanjaSo2005 | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 1 ms | 468 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 ll long long
using namespace std;
int N,niz[130],stepen[10],gde[130];
bool locked[130];
string ps;
vector<int> ret,poz;
void add(){
stepen[0]=1;
for(int i=1;i<=7;i++)
stepen[i]=stepen[i-1]*2;
ps="";
for(int i=1;i<=N;i++)
ps.push_back('1');
for(int i=1;i<=7;i++){
ps[i-1]='0';
add_element(ps);
}
for(int i=0;i<N;i++)
niz[i]=i;
for(int it=0;stepen[it]<N;it++){
for(int i=0;i<ps.size();i++)
ps[i]='0';
for(int i=0;i<it;i++)
ps[i]='1';
for(int i=it;i<N;i++)
if(i&stepen[it]){
ps[i]='1';
add_element(ps);
ps[i]='0';
}
}
return;
}
void read(){
ret.resize(N);
for(int it=0;stepen[it]<N;it++){
///Trazi gde je it-1
if(it!=0){
int traz=0;
for(int j=0;j<it;j++)
if((it-1)&stepen[j])
traz+=stepen[j];
for(int i=0;i<N;i++)
ps[i]='1';
for(int i=0;i<poz.size();i++)
ps[poz[i]]='0';
for(int i=0;i<N;i++){
if(locked[i])
continue;
if(gde[i]!=traz)
continue;
ps[i]='0';
if(check_element(ps)){
locked[i]=true;
gde[i]=it-1;
poz.push_back(i);
break;
}
else
ps[i]='1';
}
}
for(int i=0;i<N;i++)
ps[i]='0';
for(int i=0;i<poz.size();i++)
ps[poz[i]]='1';
for(int i=0;i<N;i++){
if(locked[i])
continue;
ps[i]='1';
if(check_element(ps))
gde[i]+=stepen[it];
ps[i]='0';
}
}
for(int i=0;i<N;i++)
ret[i]=gde[i];
}
vector<int> restore_permutation(int n, int w, int r) {
N=n;
add();
compile_set();
read();
return ret;
}
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... |