社区讨论
44分,求条,玄关
P1106删数问题参与者 2已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mli0cdpv
- 此快照首次捕获于
- 2026/02/11 20:30 上周
- 此快照最后确认于
- 2026/02/11 21:15 上周
CPP
#include<bits/stdc++.h>
using namespace std;
int n;
string st;
string t2[255];//
int d2[255];//
struct node{
string t;//
int d;//
}a[100001];//
bool cmp(node x,node y){
return x.t<y.t;
}
int main(){
cin>>st>>n;
int len=st.size();//
if(len==n){
cout<<st<<endl;
return 0;
}
for(int i=0;i<len;i++){
a[i+1].t=st[i];
a[i+1].d=i+1;
}
sort(a+1,a+1+len,cmp);
for(int i=1;i<=len;i++){
int cnt=1;//
t2[255]={0};
d2[255]={0};
t2[cnt]=a[i].t;
d2[cnt]=a[i].d;
for(int j=1;j<=len;j++){
if(a[j].d>d2[cnt]){
cnt++;
t2[cnt]=a[j].t;
d2[cnt]=a[j].d;
}
if(cnt==len-n){
for(int i=1;i<=len-n;i++){
cout<<t2[i];
}
return 0;
}
}
}
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...