qiuzhu
  • 板块学术版
  • 楼主ACRETLEWA
  • 当前回复6
  • 已保存回复6
  • 发布时间2024/4/6 15:10
  • 上次更新2024/4/6 16:45:51
查看原帖
qiuzhu
774340
ACRETLEWA楼主2024/4/6 15:10
#include<bits/stdc++.h>
using namespace std;

int main(){
//int n, m;
string s1, s2;
int n , m;
	cin  >> n >> m;
	cin >> s1 >> s2;
	int b[n + 1][m + 1];
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			b[i][j] = 0;
		}
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			if(s1[i] == s2[j]){
				b[i + 1][j + 1] = b[i][j] + 1;
			}
			else{
				b[i + 1][j + 1] = b[i + 1][j] > b[i][j + 1] ? b[i + 1][j] : b[i][j + 1];
			}
		}
	}
	cout << b[n][m] + 0;
	return 0;
}

https://www.luogu.com.cn/problem/T335893

file:///C:/Users/41251/Desktop/VJ)_IMYM@OG8J_G2K3QNRAI.png_IMYM@OG8J_G2K3QNRAI.png)

wei sheng mo zhi de le 10 fen?

2024/4/6 15:10
加载中...