# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
728889 | nguyentunglam | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 2 ms | 468 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 <vector>
#include<bits/stdc++.h>
using namespace std;
#include "messy.h"
vector<int> p;
int n;
void prepare(int l, int r) {
if (l == r) return;
int mid = l + r >> 1;
string x; for(int i = 0; i < n; i++) x.push_back('1');
for(int i = l; i <= r; i++) x[i] = '0';
for(int i = l; i <= mid; i++) {
x[i] = '1';
add_element(x);
x[i] = '0';
}
prepare(l, mid); prepare(mid + 1, r);
}
void solve(int l, int r, vector<int> lst) {
if (l == r) {
p[lst[0]] = l;
return;
}
int mid = l + r >> 1;
string x; for(int i = 0; i < n; i++) x.push_back('1');
for(int &j : lst) x[j] = '0';
vector<int> Left, Right;
for(int &j : lst) {
x[j] = '1';
if (check_element(x)) Left.push_back(j);
else Right.push_back(j);
x[j] = '0';
}
solve(l, mid, Left); solve(mid + 1, r, Right);
}
std::vector<int> restore_permutation(int _n, int w, int r) {
n = _n;
p.resize(n);
prepare(0, n - 1);
compile_set();
vector<int> init;
for(int i = 0; i < n; i++) init.push_back(i);
solve(0, n - 1, init);
return p;
}
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... |