2 条题解
-
1
随便秒杀的小题
#include <bits/stdc++.h> #define endl '\n' using namespace std; const int N=1e5+5,INF=0x3f3f3f3f,MOD=1e9+7; const int dx[]={1,-1,0,0},dy[]={0,0,1,-1}; typedef long long LL; string a,b; int lena,lenb; int main() { ios::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); cin>>lena>>a>>lenb>>b; a = " "+a,b = " "+b; vector<vector<int>>dp(lena+1,vector<int>(lenb+1)); for(int i=1;i<=lena;i++){ for(int j=1;j<=lenb;j++){ dp[i][j] = max(dp[i-1][j],dp[i][j-1]); if(a[i]==b[j])dp[i][j] = max(dp[i-1][j-1]+1,dp[i][j]); } } cout<<dp[lena][lenb]<<endl; return 0; }
信息
- ID
- 1783
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 37
- 已通过
- 5
- 上传者