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... |