# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50688 | Mamnoon_Siam | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 3 ms | 384 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>
using namespace std;
void add_element(std::string x);
bool check_element(std::string x);
void compile_set();
std::vector<int> restore_permutation(int n, int w, int r)
{
srand(time(0));
vector<int> ret=vector<int>(n);
for(int i=0; i<n; i++) ret[i]=-1;
string cur=string(n, '0');
for(int i=n-1; i>0; i--) {
cur[i]='1';
add_element(cur);
}
compile_set();
for(int i=0; i<cur.size(); i++) cur[i]='0';
for(int pos=n-1; pos>0; pos--) {
vector<int> foo;
for(int i = 0; i < n; i++) {
if(cur[i] == '0') {
foo.push_back(i);
}
}
random_shuffle(foo.begin(), foo.end(), [](int i){return rand()%i;});
for(int i : foo) {
string temp = cur; temp[i] = '1';
if(check_element(temp) == 1) {
cur = temp;
ret[i] = pos;
goto siam;
}
}
siam : ;
}
for(int i=0; i<n; i++) {
if(ret[i]==-1) {
ret[i]=0;
break;
}
}
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... |