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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
int a, b;
void add(string s){
a--;
assert(a);
add_element(s);
}
bool check(string s){
b--;
assert(b);
return check_element(s);
}
vector<int> restore_permutation(int n, int w, int r) {
a = w;
b = r;
// add_element("0");
// compile_set();
// check_element("0");
// return std::vector<int>();
for (int i = 0; i < n; i++){
string s = "";
for (int j = 0; j < n; j++){
if (j <= i) s += "1";
else s += "0";
}
add(s);
}
compile_set();
vector <int> curr;
for (int i = 0; i < n; i++) curr.push_back(i);
vector <int> p(n);
string s;
for (int i = 0; i < n; i++) s += "0";
int id = 0;
while (curr.size()){
random_shuffle(curr.begin(), curr.end());
int got = -1;
for (auto x : curr){
if (x == curr.back()){
got = x; break;
}
string str = s;
str[x] = '1';
if (check(str)){
got = x;
break;
}
}
assert(got != -1);
vector <int> nc;
for (auto x : curr){
if (x != got) nc.push_back(x);
}
curr = nc;
s[got] = '1';
p[id++] = got;
}
return p;
}
# | 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... |