当前位置: 首页 > news >正文

【25.10.28】模拟赛

T1

code

#include<bits/stdc++.h>
using namespace std;
const int N=5e4+5,M=1e3+5;
int n,m,ans=0;
char s[N],t[M];
int nxt[M];
int f[N][M];
int g[M][30];
void getnxt(){nxt[1]=0;int j=0;for(int i=2;i<=m;++i){while(j>0&&t[i]!=t[j+1])  j=nxt[j];if(t[i]==t[j+1])  ++j;nxt[i]=j;}
}
void getval(){for(int i=0;i<m;++i){for(int c=0;c<26;++c){int j=i;while(j>0&&c!=t[j+1]-'a')  j=nxt[j];if(c==t[j+1]-'a')  ++j;g[i][c]=j;
//			cout<<i<<" "<<c<<" "<<g[i][c]<<endl;}}
}
//int calc(int pos,char c){
//	int j=pos;
//	while(j>0&&c!=t[j+1])  j=nxt[j];
//	if(c==t[j+1])  ++j;
//	cout<<pos<<" "<<c<<" "<<j<<endl;
//	return j;
//}
int main(){freopen("neck.in","r",stdin);freopen("neck.out","w",stdout);cin>>s+1;cin>>t+1;n=strlen(s+1);m=strlen(t+1);getnxt();getval();for(int i=0;i<n;++i)for(int j=0;j<m;++j){int val=g[j][s[i+1]-'a'];f[i+1][j]=max(f[i+1][j],f[i][j]);if(val==m)  continue;f[i+1][val]=max(f[i+1][val],f[i][j]+1);}for(int i=0;i<m;++i)ans=max(ans,f[n][i]);printf("%d\n",ans);fclose(stdin);fclose(stdout);return 0;
}
http://www.jsqmd.com/news/24936/

相关文章:

  • CSP-S模拟41
  • Linux双中文编码笔记
  • C++类和对象(1) - 详解
  • 人工智能之编程基础 Python 入门:第二章 Python 的编辑器 VS Code
  • 2019 福建省队集训录
  • AIX multibos bootlist
  • 记录一次nginx能通但是请求一直不了的问题
  • 【嵌入式】PWM DAC的滤波器设计
  • 被称作遗憾之物 爬满了脊骨 又把控了痛楚 被称作无用之物 修筑了唯一的通路
  • neovim在windwos11下snack.nvim的问题
  • 完整教程:Java 集合 “List + Set”面试清单(含超通俗生活案例与深度理解)
  • 禁用 IPython 历史记录 history.sqlite
  • Luogu P7914 [CSP-S 2021] 括号序列 题解 [ 蓝 ] [ 区间 DP ] [ 前缀和优化 ] [ 调试技巧 ]
  • 扩展BaseMapper类 - 详解
  • 《程序员修炼之道:从小工到专家》前五分之二观后感
  • 矩阵快速幂章节笔记(这里主要介绍的是我的错题)
  • 实验二 现代C++编程初体验
  • P5322 [BJOI2019] 排兵布阵
  • 题解:P9292 [ROI 2018] Robomarathon
  • [题解]P5322 [BJOI2019] 排兵布阵
  • 考前打印
  • 申威服务器安装Nacos 2.0.3 RPM包详细步骤(Kylin V10 sw_64架构)​附安装包
  • ZKY精选冲刺省选国赛仿真训练题
  • MySQL 查询与更新语句执行过程深度解析:从原理到实践​ - 指南
  • ZKY精选冲刺省选国赛技巧训练题
  • 逆向基础--编码(001)
  • 20251027 - 倍增 ST表
  • 周康阳精选冲刺省选国赛思维训练题
  • Luogu P7913 [CSP-S 2021] 廊桥分配 题解 [ 绿 ] [ 贪心 ] [ 前缀和 ] [ STL ]
  • 10-27 CSP 赛前比赛记录