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 "messy.h"
#include <iostream>
using namespace std;
int ans[100005],tag[100005],N;
void add(int s,int e)
{
if(s==e)return ;
int mid=(s+e)/2;
string str="";
for(int i=0;i<N;i++)str+='0';
for(int i=0;i<s;i++)str[i]='1';
for(int i=e+1;i<N;i++)str[i]='1';
for(int i=s;i<=mid;i++)
{
str[i]='1';
add_element(str);
str[i]='0';
}
add(s,mid);
add(mid+1,e);
}
int find(int s,int e)
{
//cout<<s<<" "<<e<<endl;
if(s==e)
{
for(int i=0;i<N;i++)
{
if(tag[i]==0)ans[i]=s;
}
return 0;
}
string str="";
for(int i=0;i<N;i++)str+='0';
for(int i=0;i<N;i++)if(tag[i]==1)str[i]='1';
int tmp[1005];
for(int i=0;i<N;i++)tmp[i]=0;
for(int i=0;i<N;i++)
{
if(tag[i]==0)
{
str[i]='1';
//cout<<str<<" ";
bool c=check_element(str);
//cout<<c<<endl;
if(c==1)tmp[i]=1;
else tmp[i]=2;
str[i]='0';
}
}
for(int i=0;i<N;i++)
{
if(tmp[i]==0 || tmp[i]==2)tag[i]=1;
else tag[i]=0;
}
find(s,(s+e)/2);
for(int i=0;i<N;i++)
{
if(tmp[i]==0 || tmp[i]==1)tag[i]=1;
else tag[i]=0;
}
find((s+e)/2+1,e);
}
std::vector<int> restore_permutation(int n, int w, int r) {
N=n;
add(0,n-1);
compile_set();
find(0,n-1);
vector<int>a(n);
for(int i=0;i<n;i++)
{
a[i]=ans[i];
}
return a;
}
Compilation message (stderr)
messy.cpp: In function 'int find(int, int)':
messy.cpp:36:13: warning: control reaches end of non-void function [-Wreturn-type]
36 | string str="";
| ^~
# | 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... |