# UVA 10635 Prince and Princess

#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <utility>
using namespace std;

#define rep(i,j,k) for (int i=j;i<=k;i++)
#define Rrep(i,j,k) for (int i=j;i>=k;i--)

#define Clean(x,y) memset(x,y,sizeof(x))
#define LL long long
#define ULL unsigned long long
#define inf 0x7fffffff
#define mod 100000007
const int maxn = 70000;
int T;
int n,p,q;
map<int,int> pos;

int f[maxn];

int query(int x)
{
int ans = 0;
while( x > 0 )
{
ans = max( ans , f[x] );
x -= x & (-x);
}
return ans;
}
{
while( x <= n )
{
f[x] = max( k , f[x] );
x += x & (-x);
}
}

void init()
{
int temp;
cin>>n>>p>>q;
n*=n;
pos.clear();
rep(i,1,p+1)
{
scanf("%d",&temp);
pos[temp] = i;
}
Clean(f,0);
}

int solve()
{
int temp;
int ans = 0;
rep(i,1,q+1)
{
scanf("%d",&temp);
if ( pos[temp] == 0 )continue;
temp = pos[temp];
int x = query(temp-1);
ans = max( ans , x+1 );
}
return ans;
}
int main()
{
cin>>T;
rep(kase,1,T)
{
init();
printf("Case %d: %d\n",kase,solve());
}
return 0;
}

• 本文已收录于以下专栏：

举报原因： 您举报文章：UVA 10635 Prince and Princess 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)