题意:最长公共子序列
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int arr[25],brr[25],dp[25][25];
int main(){
int n,t;
scanf("%d",&n);
for (int i = 1; i <= n; i++){
scanf("%d",&t);
arr[t-1] = i;
}
while (scanf("%d",&t) != EOF){
brr[t-1] = 1;
for (int i = 2; i <= n; i++){
scanf("%d",&t);
brr[t-1] = i;
}
memset(dp,0,sizeof(dp));
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++){
if (arr[i-1] == brr[j-1])
dp[i][j] = dp[i-1][j-1] + 1;
else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
}
printf("%d\n",dp[n][n]);
}
return 0;
}