#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define MAX 1000
int M,N,LCS[1000+5][1000+5];
class set{
public:
int element[MAX];
int card;
};
int lcs(set A,set B)
{ int M=A.card,N=B.card;
int i,j;
for(i=0;i<1005;i++)LCS[i][0]=0;
for(j=0;j<1005;j++)LCS[0][j]=0;
for(i=1;i<=M;i++)
for(j=1;j<=N;j++)
{
if(A.element[i-1]==B.element[j-1])LCS[i][j]=LCS[i-1][j-1]+1;
else LCS[i][j]=max(LCS[i-1][j],LCS[i][j-1]);
}
return LCS[M][N];
}
void print(int res,int M,int N)
{ if(res==0)cout<<"A and B are disjoint"<<endl;
else if(M!=N){if(res==M)cout<<"A is a proper subset of B"<<endl;
else if(res==N)cout<<"B is a proper subset of A"<<endl;
else cout<<"I'm confused!"<<endl;
}
else if(M==N){if(res==M)cout<<"A equals B"<<endl;
else cout<<"I'm confused!"<<endl;
}
return ;
}
int main()
{
while(1){ set S[2];
M=N=0;
char inp1[MAX],inp2[MAX];
gets(inp1);
if(feof(stdin))break;
char *p1;
p1=strtok(inp1," ");
while(p1!=NULL){ S[0].element[M++]=atoi(p1);
p1=strtok(NULL," ");
}
S[0].card=M;
gets(inp2);
char *p2;
p2=strtok(inp2," ");
while(p2!=NULL){ S[1].element[N++]=atoi(p2);
p2=strtok(NULL," ");
}
S[1].card=N;
sort(S[0].element,S[0].element+M);
sort(S[1].element,S[1].element+N);
int res=lcs(S[0],S[1]);
print(res,M,N);
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন