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>
#include "messy.h"
using namespace std;
typedef int ll;
ll N;
ll arr[128];
void add(ll l, ll r) {
if (l == r) return;
ll i;
string s;
s.resize(N);
for (i = 0; i < N; i++) s[i] = '0';
for (i = 0; i < l; i++) s.replace(s.begin() + i, s.begin() + i + 1, "1");
for (i = r + 1; i < N; i++) s.replace(s.begin() + i, s.begin() + i + 1, "1");
ll mid = (l + r) >> 1;
for (i = mid + 1; i <= r; i++) {
s.replace(s.begin() + i, s.begin() + i + 1, "1");
add_element(s);
s.replace(s.begin() + i, s.begin() + i + 1, "0");
}
add(l, mid);
add(mid + 1, r);
}
void check(ll x, ll k) {
if (!k) return;
ll i;
string s;
s.resize(N);
for (i = 0; i < N; i++) {
if (arr[i] == x) s[i] = '0';
else s[i] = '1';
}
for (i = 0; i < N; i++) {
if (s[i] == '0') {
s[i] = '1';
if (check_element(s)) arr[i] += k;
s[i] = '0';
}
}
check(x, k / 2);
check(x + k, k / 2);
}
std::vector<int> restore_permutation(int n, int w, int r) {
N = n;
add(0, N - 1);
compile_set();
check(0, N / 2);
vector<ll> res;
ll i;
res.resize(N);
for (i = 0; i < N; i++) {
res[i] = arr[i];
}
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... |