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 <vector>
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> restore_permutation(int n, int w, int r) {
// add_element("0");
// compile_set();
// check_element("0");
string x(n, '0');
for (int i = 0; i < n; ++i) {
x[i] = '1';
add_element(x);
}
compile_set();
int mask[n+1];
for (int i = 0; i < (1<<n); ++i) {
int cnt = 0;
string s = "";
for (int j = 0; j < n; ++j) if (i&(1<<j)) s += '1', ++cnt; else s += '0';
bool found = check_element(s);
if (found) {
//cout << cnt << ": " << s << endl;
mask[cnt] = i;
}
}
//cout << "COMPILED" << endl;
vector<int> p(n, 0);
mask[0] = 0;
for (int i = 1; i <= n; ++i) {
int cur = mask[i] ^ mask[i-1];
//cout << mask[i] << " : ";
//for (int j = 0; j < n; ++j) if (cur&(1<<j)) cout << '1'; else cout << '0'; cout << endl;
for (int j = 0; j < n; ++j) if (cur & (1<<j)) {
//cout << "ASSIGN " << j << " " << i << endl;
p[j] = i-1;
}
}
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... |