这道题可以贪心 维护一个答案队列 枚举位置 每次将比当前位置大的队尾全部替代掉 记录删了多少了就好了

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#define LL long long
using namespace std;
const int M=1e7+;
int n,k,cnt;
char s[M],q[M];
int main()
{
freopen("del.in","r",stdin);
freopen("del.out","w",stdout);
scanf("%s",s+);
n=strlen(s+); scanf("%d",&k);
int v=n-k;
q[++cnt]=s[];
for(int i=;i<=n;i++){
while(cnt&&q[cnt]>s[i]&&v) cnt--,v--;
q[++cnt]=s[i];
}
for(int i=;i<=k;i++) printf("%c",q[i]); printf("\n");
return ;
}

当然 序列自动机比较明显 但是会慢很多

#include<cstdio>
#include<cstring>
const int M=;
int n,k,c[M][],deep[M];
char s[M];
void maxs(int& x,int y){if(x<y) x=y;}
int main(){
freopen("del.in","r",stdin);
freopen("del.out","w",stdout);
scanf("%s",s+);
n=strlen(s+);
scanf("%d",&k);
for(int i=;i<=n;i++){
int now=s[i]-'a';
for(int j=i;j&&!c[j][now];c[j--][now]=i+);
}
for(int i=n;i>=;i--){
for(int j=;j<;j++){
int v=c[i][j];
if(v) maxs(deep[i],deep[v]+);
}
}
int now=;
for(int l=k;l;l--){
for(int j=;j<;j++){
int v=c[now][j];
if(v&&deep[v]>=l-){
now=v;
putchar('a'+j);
break;
}
}
}
return ;
}

最新文章

  1. 【linux使用】bash shell命令行常用快捷键 (转载)
  2. KindEditor上传本地图片在ASP.NET MVC的配置
  3. HttpClient设置代理,超时,以及得到cookies
  4. transition的四个属性
  5. CODEVS 3139 栈练习3
  6. ASP.NET实现列表页连接查询 拼接sql语句 绑定grivdView
  7. 关于js封装框架类库之样式操作
  8. gtk+blade+anjuta 的简单实例
  9. docker~linux下的部署和基本命令
  10. Maven依赖的是本地工程还是仓库jar包?
  11. Gauge----自动化测试工具--使用
  12. python中使用redis发布订阅者模型
  13. 源码来袭:bind手写实现
  14. ADO五大对象
  15. SpringBoot-@PathVariable
  16. IntelliJ IDEA 中SpringBoot对Run/Debug Configurations配置 SpringBoot热部署
  17. 基于asp.net + easyui框架,一步步学习easyui-datagrid——实现分页和搜索(二)
  18. Redis客户端连接以及持久化数据(三)
  19. git clone Google的代码失败的解决方法
  20. MySQL学习笔记:insert into select

热门文章

  1. 第三课:PHP 语法
  2. Linux(CentOS6.5 x64)下版本安装及升级kangle+EasyPanel
  3. HTTP 响应时发生错误。这可能是由于服务终结点绑定未使用 HTTP 协议造成的。这还可能是由于服务器中止了 HTTP 请求上下文(可能由于服务关闭)所致。
  4. 裸机——I2C
  5. [Link-Cut-Tree][BZOJ2002]弹飞绵羊
  6. 2037: [Sdoi2008]Sue的小球
  7. 3226: [Sdoi2008]校门外的区间
  8. 关于requestMapping 进行url映射实现小小知识点 以及如何获取请求的url中的参数
  9. linux 多播
  10. X的N次方。N比较大。