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;
}

uva10635Prince and Princess(LIS)

2014-08-13 21:43:57

UVA - 10635 Prince and Princess

2013-09-25 17:30:43

uva 10635 Prince and Princess

2014-10-21 17:46:15

Prince and Princess UVa 10635

2018-04-20 12:14:54

uva 10635 - Prince and Princess

2013-09-20 12:55:03

UVA 10635 Prince and Princess

2013-08-09 16:01:48

Prince and Princess UVA - 10635

2018-03-26 17:30:12

UVA - 10635 —— Prince and Princess

2016-05-18 21:35:17

UVA 10635 - Prince and Princess

2014-03-20 23:52:45

UVA - 10635 Prince and Princess

2014-11-10 21:56:40