Daniel141130 @ 2023-12-06 09:09:17
代码献上
#include <cstring>
#include <iostream>
using namespace std;
int n, m, a[3086], b[3086], f[2][100086];
int LCS (int l, int k) {
for (int i = 1; i <= l; i++) {
for (int j = 1; j <= k; j++) {
if (a[i] == b[j]) f[i & 1][j] = f[i - 1 & 1][j - 1] + 1;
else f[i & 1][j] = max (f[i - 1 & 1][j], f[i & 1][j - 1]);
}
}
return f[l & 1][k];
}
int main(){
//freopen ("P1439_2.in", "r", stdin);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int j = 1; j <= n; j++) cin >> b[j];
cout << LCS (n, n) << endl;
return 0;
}
by Terrible @ 2023-12-06 09:40:25
by AC_love @ 2023-12-06 10:46:21
有没有一种可能,
by Daniel141130 @ 2023-12-06 13:22:09
关键错误类型是WA和CE