# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50692 | faishol27 | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 3 ms | 432 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.
////////////////////////////////////////////////
// //
// Author: Muhammad Faishol Amirul Mukminin //
// //
////////////////////////////////////////////////
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>ans;
string solve(int cnt, string s){
string ret = s;
int len = s.length(),
terkiri;
for(int i=len-1;i>=0;i--)
if(ret[i] == '0'){
terkiri = i;
break;
}
for(int i=0;i<terkiri;i++){
if(ret[i]=='1') continue;
ret[i] = '1';
if(check_element(ret)){
ans[i] = cnt-1;
return ret;
}else{
ret[i] = '0';
}
}
ans[terkiri] = cnt-1;
ret[terkiri] = '1';
return ret;
}
std::vector<int> restore_permutation(int N, int W, int R) {
ans.resize(N, -1);
string B = "",
tmp = "";
for(int i=0;i<N;i++){
B += "0";
tmp += "0";
}
for(int i=0;i<N-1;i++){
B[i] = '1';
add_element(B);
}
compile_set();
for(int i=1;i<N;i++){
tmp = solve(i, tmp);
}
for(int i=0;i<N;i++) if(ans[i]==-1) ans[i] = N-1;
return std::vector<int>(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... |