//\\__ hr1212 __//\\
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
int n,m;
map<int,int> mm;
int a[1000000],b[1000000],c[1000000];
int main(){
int r,k,i,x=0,y=0,j,t,l,z,x1=0,y1=0;
int n,p,q;
int cnt=1;
scanf("%d",&t);
while(t--)
{
scanf("%d %d %d",&n,&p,&q);
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(int i=1;i<=p+1;i++)
{
scanf("%d",&x);
a[x]=i;
}
for(int i=1;i<=q+1;i++)
{
scanf("%d",&x);
if(a[x])
b[i]=a[x];
else
b[i]=-1;
}
vector<int> c(1000000,999999);
for(int i=1;i<=q+1;i++)
*upper_bound(c.begin(),c.end(),b[i])=b[i];
for(z=0;z<=1000000;z++)
{
if(c[z]==999999)
break;
}
printf("Case %d: %d\n",cnt++,z);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
int n,m;
map<int,int> mm;
int a[1000000],b[1000000],c[1000000];
int main(){
int r,k,i,x=0,y=0,j,t,l,z,x1=0,y1=0;
int n,p,q;
int cnt=1;
scanf("%d",&t);
while(t--)
{
scanf("%d %d %d",&n,&p,&q);
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(int i=1;i<=p+1;i++)
{
scanf("%d",&x);
a[x]=i;
}
for(int i=1;i<=q+1;i++)
{
scanf("%d",&x);
if(a[x])
b[i]=a[x];
else
b[i]=-1;
}
vector<int> c(1000000,999999);
for(int i=1;i<=q+1;i++)
*upper_bound(c.begin(),c.end(),b[i])=b[i];
for(z=0;z<=1000000;z++)
{
if(c[z]==999999)
break;
}
printf("Case %d: %d\n",cnt++,z);
}
return 0;
}
No comments:
Post a Comment