样例过了,爆零
对顶堆+贪心
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int k,m,cnt;
string s;
priority_queue<int,vector<int>,greater<int> >a;//小根堆
string itos(int x){
string s;
s.clear();
while(x){
s+=x%10+'0';
x/=10;
}
reverse(s.begin(),s.end());
return s;
}
void init(){//用小根堆维护序列
int top=a.top();
a.pop();
a.push(2*top+1);
a.push(4*top+5);
s+=itos(top);
}
int main(){
cin>>k>>m;
a.push(1);
while(k--) init();
cout<<s<<endl;
//删数
int l=s.length();
for(int i=1;i<=m;++i)
for(int j=0;j<l;++j)
if(s[j]<s[j+1]){
s.erase(j,1);
break;
}
for(int i=0;i<l;++i)
if(s[i]=='0') s.erase(i,1);
cout<<s<<endl;
}