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 <set>
#include <cstdlib>
#include <iostream>
#include "messy.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int (i) = 0; (i) < (n); (i)++)
void build(int l, int r, int n)
{
if (l + 1 == r)
{
return;
}
int m = (l + r) / 2;
for (int i = l; i < m; i++)
{
string s(n, '1');
for (int j = l; j < r; j++)
s[j] = '0';
s[i] = '1';
add_element(s);
}
build(l, m, n);
build(m, r, n);
}
void restore(int n, vector<int> sc, int l, int r, vector<int> &ans)
{
if (l + 1 == r)
{
ans[l] = sc[0];
return;
}
string s(n, '1');
for (auto e : sc)
s[e] = '0';
vector<int> on, off;
for (auto e : sc)
{
s[e] = '1';
if (check_element(s))
on.push_back(e);
else
off.push_back(e);
s[e] = '0';
}
int m = (l + r) / 2;
restore(n, on, l, m, ans);
restore(n, off, m, r, ans);
}
vector<int> restore_permutation(int n, int w, int r)
{
build(0, n, n);
compile_set();
vector<int> ans(n);
vector<int> sc;
for (int i = 0; i < n; i++) sc.push_back(i);
restore(n, sc, 0, n, ans);
return ans;
}
# | 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... |