Pagini recente » Cod sursa (job #569918) | Cod sursa (job #1712491) | Cod sursa (job #1346565) | Cod sursa (job #2762353) | Cod sursa (job #1725047)
#include <cstdio>
#include <algorithm>
#define MAX 1000000
using namespace std;
char f[MAX];
int pos=0,N,L1,L2,x,P=0;
long long v1[501]={},v2[501]={};
void r(int &nr)
{
int sign=0;
nr=0;
while(f[pos]<'0'||f[pos]>'9')
{
pos++;
if(f[pos]=='-')
sign=1;
}
while(f[pos]>='0'&&f[pos]<='9')
nr=nr*10+f[pos++]-'0';
if(sign==1)
nr=-nr;
}
bool Analise(long long A[],long long B[])
{
int pos1=1,pos2=1;
while(pos1<=L1||pos2<=L2)
{
while(A[pos1]==A[pos1+1])
pos1++;
while(B[pos2]==B[pos2+1])
pos2++;
if(A[pos1]!=B[pos2])
return false;
else
{
pos1++;
pos2++;
}
if(pos1==L1&&pos2==L2)
break;
}
return true;
}
int main()
{
freopen("amlei.in","r",stdin);
freopen("amlei.out","w",stdout);
//fread(f,1,MAX,stdin);
while(scanf("%d",&N)!=EOF)
{
scanf("%d%d",&L1,&L2);
//r(N);r(L1);r(L2);
long long v1[501]={},v2[501]={};
for(int i=1;i<=L1;i++)
for(int j=1;j<=N;j++)
{
scanf("%d",&x);
//r(x);
if(x<0)
v1[i]+=1<<abs(x);
}
for(int i=1;i<=L2;i++)
for(int j=1;j<=N;j++)
{
scanf("%d",&x);
//r(x);
if(x<0)
v2[i]+=1<<abs(x);
}
sort(v1+1,v1+L1+1);
sort(v2+1,v2+L2+1);
if(Analise(v1,v2))
printf("DA\n");
else printf("NU\n");
}
return 0;
}