#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int *num;
int top;
}sq;
void st(sq &l,int e)
{
l.top=0;
l.num=(int *)malloc(e*sizeof(int));
}
void push (sq &l,int e)
{
l.num[l.top]=e;
l.top++;
}
int main()
{
sq l;
int i,n,t;
int a[10500],b[10500];
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
scanf("%d",&t);
while(t)
{
t--;
for (i=0;i<n;i++)
{
scanf("%d",&b[i]);
}
st(l,n);
int nn=0,mm=0;
while(nn<n)
{
if(a[nn]==b[mm])
{
nn++;
mm++;
}
else
{
push(l,a[nn]);
nn++;
}
}
int flag=1;
while(l.top!=0)
{
l.top--;
if(b[mm]!=l.num[l.top])
{
flag=0;
break;
}
mm++;
}
if(flag==1)
{
printf("yes\n");
}
else
{
printf("no\n");
}
}
return 0;
}
/**************************************
Problem id : SDUT OJ A
User name : wy150318王鹏鹏
Result : Accepted
Take Memory : 476K
Take Time : 10MS
Submit Time : 2016-08-01 20:44:34
**************************************/
#include <stdlib.h>
typedef struct
{
int *num;
int top;
}sq;
void st(sq &l,int e)
{
l.top=0;
l.num=(int *)malloc(e*sizeof(int));
}
void push (sq &l,int e)
{
l.num[l.top]=e;
l.top++;
}
int main()
{
sq l;
int i,n,t;
int a[10500],b[10500];
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
scanf("%d",&t);
while(t)
{
t--;
for (i=0;i<n;i++)
{
scanf("%d",&b[i]);
}
st(l,n);
int nn=0,mm=0;
while(nn<n)
{
if(a[nn]==b[mm])
{
nn++;
mm++;
}
else
{
push(l,a[nn]);
nn++;
}
}
int flag=1;
while(l.top!=0)
{
l.top--;
if(b[mm]!=l.num[l.top])
{
flag=0;
break;
}
mm++;
}
if(flag==1)
{
printf("yes\n");
}
else
{
printf("no\n");
}
}
return 0;
}
/**************************************
Problem id : SDUT OJ A
User name : wy150318王鹏鹏
Result : Accepted
Take Memory : 476K
Take Time : 10MS
Submit Time : 2016-08-01 20:44:34
**************************************/