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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> useless, ans;
bool exist[130];
int N, cnt;
string str;
void recur1(int L, int R)
{
if (L==R)
return;
int mid=(L+R)/2;
for (int i=L; i<=mid; i++)
{
string tmp=str;
for (int j=0; j<N; j++)
if (j<L || j>R || j==i)
tmp[j]='1';
add_element(tmp);
}
recur1(L, mid);
recur1(mid+1, R);
}
void recur2(vector<int> v)
{
int sz=v.size();
if (sz==1)
{
ans[v[0]]=cnt;
cnt++;
return;
}
for (int i=0; i<N; i++)
exist[i]=0;
for (int i=0; i<sz; i++)
exist[v[i]]=1;
vector<int> vec1, vec2;
for (int i=0; i<sz; i++)
{
string tmp=str;
for (int j=0; j<N; j++)
if (!exist[j] || j==v[i])
tmp[j]='1';
if (check_element(tmp))
vec1.push_back(v[i]);
else
vec2.push_back(v[i]);
}
recur2(vec1);
recur2(vec2);
}
vector<int> restore_permutation(int NN, int WW, int RR)
{
N=NN;
for (int i=0; i<N; i++)
str.push_back('0');
recur1(0, N-1);
compile_set();
for (int i=0; i<N; i++)
{
useless.push_back(i);
ans.push_back(0);
}
recur2(useless);
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... |