输入诡异
#include<bits/stdc++.h>
using namespace std;
#define fst first
#define sec second
#define sci(num) scanf("%d",&num)
#define scl(num) scanf("%lld",&num)
#define mem(a,b) memset(a,b,sizeof a)
#define cpy(a,b) memcopy(a,b,sizeof b)
typedef long long LL;
typedef pair<int,int> P;
const int MAX_N = 100;
const int MAX_M = 10000;
int x[MAX_N];
int y[MAX_N];
int dp[MAX_N][MAX_N];
int N;
void solve() {
for (int i = 1;i <= N;i++) {
for (int j = 1;j <= N;j++) {
if (x[i] == y[j]) {
dp[i][j] = dp[i - 1][j - 1] + 1;
} else {
dp[i][j] = max(dp[i][j-1],dp[i - 1][j]);
}
}
}
printf("%d\n",dp[N][N]);
}
int main() {
while (~sci(N)) {
for (int i = 1;i <= N;i++) {
int t;
sci(t);
x[t] = i;
}
int loc;
while (~sci(loc)) {
y[loc] = 1;
for (int i = 2;i <= N;i++)
{
sci(loc);
y[loc] = i;
}
solve();
}
}
return 0;
}