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 <random>
#include <vector>
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
string get_string(int n, int ones = 0) {
return string(ones, '1') + string(n - ones, '0');
}
std::vector<int> restore_permutation(int n, int w, int r) {
vector<int> p(n, -1);
for (int i = 0; i < n; i++) {
add_element(get_string(n, i + 1));
}
compile_set();
vector<int> ord(n);
for (int i = 0; i < n; i++) ord[i] = i;
for (int i = 0; i < n; i++) {
string s = get_string(n, i);
string t = get_string(n, 0);
for (int j = 0; j < n; j++) {
if (p[j] != -1) t[j] = s[p[j]];
}
s = t;
// cerr << s << endl;
shuffle(ord.begin(), ord.end(), std::mt19937(std::random_device()()));
for (int j :ord) {
if (s[j] != '1' && p[j] == -1) {
s[j] = '1';
// cerr << "\t" << s << endl;
if (check_element(s)) {
p[j] = i;
// cerr << j << endl;
break;
}
s[j] = '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... |