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;
std::vector<int> restore_permutation(int n, int w, int r) {
vector<int>ans;
for(int i=0;i<n;i++){
ans.push_back(0);
}
queue<pair<int,int>>q;
q.push({0,n-1});
vector<string>cek;
while(!q.empty()){
pair<int,int>ro=q.front();
q.pop();
if((ro.second-ro.first)>=1){
int a=ro.first;
int b=ro.second;
int ti=(a+b)/2;
for(int i=a;i<=ti;i++){
string s="";
for(int j=0;j<a;j++){
s=s+'0';
}
for(int j=a;j<=b;j++){
if(j!=i){
s=s+'1';
}else{
s=s+'0';}
}
for(int j=b+1;j<n;j++){
s=s+'0';
}
add_element(s);
}
}
}
queue<pair<pair<int,int>,vector<int>>>q1;
vector<int>v;
for(int i=0;i<n;i++){
v.push_back(i);
}
q1.push({{0,n-1},v});
compile_set();
while(!q1.empty()){
pair<pair<int,int>,vector<int>>ro=q1.front();
q1.pop();
int a=ro.first.first;
int b=ro.first.second;
v=ro.second;
if(a==b){
ans[a]=v[0];
}else{
vector<int>v1;
vector<int>v2;
int ti=(a+b)/2;
for(int i=a;i<=b;i++){
string s1="";
for(int j=0;j<a;j++){
s1=s1+'0';
}
for(int j=a;j<=b;j++){
if(j!=i){
s1=s1+'1';
}else{
s1=s1+'0';}
}
for(int j=b+1;j<n;j++){
s1=s1+'0';
}
if(check_element(s1)==true){
v1.push_back(i);
}else{
v2.push_back(i);}
}
q1.push({{a,ti},v1});
q1.push({{ti+1,b},v2});
}
}
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... |