[LUOGU] P2543 [AHOI2004]奇怪的字符串
2024-09-08 03:57:56
LCS
//Writer:GhostCai && His Yellow Duck
#include<iostream>
#include<cstring>
#define MAXN 5000
using namespace std;
char s[MAXN],t[MAXN];
int lens,lent;
int f[MAXN][MAXN];
int main() {
cin>>s+1>>t+1;
memset(f,0,sizeof(f));
lens=strlen(s+1);
lent=strlen(t+1);
for(int i=1; i<=lens; i++) {
for(int j=1; j<=lent; j++) {
if(s[i]==t[j]) {
f[i][j]=f[i-1][j-1]+1;
} else {
f[i][j]=max(f[i-1][j],f[i][j-1]);
}
}
}
cout<<f[lens][lent]<<endl;
return 0;
}
最新文章
- GPS部标平台的架构设计(十)-基于Asp.NET MVC构建GPS部标平台
- java插入排序
- ASP.NET常用的SqlDbHelper类
- 泛函编程(26)-泛函数据类型-Monad-Applicative Functor Traversal
- smaller programs should improve performance
- 使用Spring的jdbcTemplate进一步简化JDBC操作
- C# 设置程序开机自动运行(+注册表项)
- 很全的corel图像分类,场景识别图像库
- Codeforces Round #321 (Div. 2) E. Kefa and Watch 线段树hash
- [LeetCode]题解(python):126-Word Ladder II
- PHP学习之-数据库操作
- C++如何入门
- KICKSTART无人值守安装
- multi-label image classification:多标签图像分类总结
- 【Apache Pulsar】Apache Pulsar单机环境及Go语言开发环境搭建
- Linux查找当前目录5天的文件并打包
- python 读写json数据
- Python3.5 学习二十四
- python-day33--Process类中的方法及属性
- PHP性能调优,PHP慢日志---善用php-fpm的慢执行日志slow log,分析php性能问题