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 n;
string make1(int lt, int rt, int x) {
string res;
for (int i = 0; i < n; i++) {
if (i != x && lt <= i && i <= rt) {
res += "0";
}
else {
res += "1";
}
}
return res;
}
void solve1(int lt, int rt) {
if (lt == rt) {
return;
}
int mt = (lt + rt) / 2;
for (int i = lt; i <= mt; i++) {
add_element(make1(lt, rt, i));
}
solve1(lt, mt);
solve1(mt + 1, rt);
}
string make2(vector<int> cand, int x) {
string res;
for (int i = 0; i < n; i++) {
if (i != x && find(cand.begin(), cand.end(), i) != cand.end()) {
res += "0";
}
else {
res += "1";
}
}
return res;
}
vector<int> res;
void solve2(int lt, int rt, vector<int> cand) {
if (lt == rt) {
res[cand[0]] = lt;
return;
}
int mt = (lt + rt) / 2;
vector<int> left;
vector<int> right;
for (auto x: cand) {
if (check_element(make2(cand, x))) {
left.push_back(x);
}
else {
right.push_back(x);
}
}
solve2(lt, mt, left);
solve2(mt + 1, rt, right);
}
vector<int> restore_permutation(int _n, int w, int r) {
n = _n;
solve1(0, n - 1);
compile_set();
vector<int> cand(n);
for (int i = 0; i < n; i++) {
cand[i] = i;
}
res.resize(n);
solve2(0, n - 1, cand);
return res;
}
# | 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... |