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"
using namespace std;
mt19937 rng(time(NULL));
std::vector<int> restore_permutation(int n, int w, int r) {
string S(n, '0'), res(n, '0');
for (int i = 0;i < n;i ++) {
S[i] = '1';
add_element (S);
}
compile_set ();
vector<int> p(n, 0), used(n, 0);
vector<int> index(n);
for (int i = 0;i < n;i ++) index.push_back(i);
shuffle(index.begin(), index.end(), rng);
function<void(int)> func = [&](int ind) -> void {
if (ind == n) return;
for (auto i : index) if (used[i] == 0) {
res[i] = '1';
if (check_element (res) == 1) {
used[i] = 1;
p[i] = ind;
break;
}
res[i] = '0';
}
func (ind + 1);
};
func (0);
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... |