This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define ld long double
#define pb push_back
int N;
string sum(string &a,string &b){
string c=a;
for(int i=0;i<b.size();i++){
if(b[i]=='1')c[i]='1';
}
return c;
}
std::vector<int> restore_permutation(int n, int w, int r){
N=n;
for(int i=1;i<N;i*=2){
for(int j=0;j<N;j+=2*i){
string x=string(N,'0');
for(int h=j;h<j+i;h++)x[h]='1';
//cout<<x<<endl;
add_element(x);
}
}
compile_set();
vector<int> v[N+2];
vector<pair<string,int> > g1,g2;
for(int i=0;i<N;i++){
string x=string(N,'0');
x[i]='1';
if(check_element(x)){
v[i].pb(1);
g1.pb({x,i});
}else{
g2.pb({x,i});
}
}
for(int i=2;i<N;i*=2){
vector<pair<string,int> > g3,g4;
for(auto [a,b]:g1){
for(auto [c,d]:g2){
string k=sum(a,c);
if(check_element(k)){
//cout<<"k: "<<k<<endl;
for(int j=0;j<N;j++)if(k[j]=='1')v[j].pb(i);
g3.pb({k,min(b,d)});
}else{
g4.pb({k,min(b,d)});
}
}
}
g1=g3;
g2=g4;
}
vector<int> ans(N);
for(int i=0;i<N;i++){
int cur=0;
for(int j:v[i])cur+=j;
//cout<<cur<<" ";
ans[i]=N-1-cur;
}
//cout<<endl;
//reverse(ans.begin(),ans.end());
return ans;
}
Compilation message (stderr)
messy.cpp: In function 'std::string sum(std::string&, std::string&)':
messy.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(int i=0;i<b.size();i++){
| ~^~~~~~~~~
# | 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... |