# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1093623 | huyngo | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 2 ms | 604 KiB |
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>
using namespace std;
#include "messy.h"
// void add_element(std::string x);
// bool check_element(std::string x);
// void compile_set();
std::vector<int> restore_permutation(int n, int w, int r) {
vector<int> perm(n);
// add phase
auto add = [&](auto self, int l, int r) -> void {
if (l == r) return;
int m = (l + r) / 2;
string s(n, '1');
for (int i = l; i <= r; ++i) s[i] = '0';
for (int i = l; i <= m; ++i) {
s[i] = '1';
add_element(s);
s[i] = '0';
}
self(self, l, (l + r) / 2);
self(self, (l + r) / 2 + 1, r);
};
add(add, 0, n - 1);
compile_set();
auto solve = [&](auto self, int l, int r, vector<int> z) -> void {
if (l == r) {
perm[z[0]] = l;
return;
}
int m = (l + r) / 2;
string s(n, '1');
for (int i : z) s[i] = '0';
vector<int> y;
for (int i : z) {
s[i] = '1';
if (check_element(s))
y.push_back(i);
s[i] = '0';
}
vector<int> t;
for (int i = 0, j = 0; i < z.size(); ++i) {
if (j < y.size() && z[i] == y[j])
++j;
else
t.push_back(z[i]);
}
self(self, l, m, y);
self(self, m + 1, r, t);
};
vector<int> z(n, 0);
iota(z.begin(), z.end(), 0);
solve(solve, 0, n - 1, z);
return perm;
}
Compilation message (stderr)
# | 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... |