# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65960 | gs13068 | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 4 ms | 512 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 <cstdio>
#include <string>
#include "messy.h"
using namespace std;
int N;
int R[128];
void push(int l, int r) {
if (r - l == 1) return;
string s(N, '0');
int i;
for (i = l; i < r; i++) s[i] = '1';
for (i = l; i < (l + r >> 1); i++) {
s[i] = '0';
add_element(s);
s[i] = '1';
}
push(l, l + r >> 1);
push(l + r >> 1, r);
}
void pop(vector<int> a, int k) {
if (a.size() == 1) {
R[a[0]] = k;
return;
}
string s(N, '0');
vector<int> l, r;
for (auto t : a) s[t] = '1';
for (auto t : a) {
s[t] = '0';
if (check_element(s)) l.push_back(t);
else r.push_back(t);
s[t] = '1';
}
pop(l, k);
pop(r, k | r.size());
}
std::vector<int> restore_permutation(int n, int w, int r) {
vector<int> res;
int i;
N = n;
push(0, n);
compile_set();
for (i = 0; i < n; i++) res.push_back(i);
pop(res, 0);
return vector<int>(R, R + n);
}
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... |