Pagini recente » Cod sursa (job #2116361) | Cod sursa (job #1097826) | Cod sursa (job #1870104) | Cod sursa (job #927652) | Cod sursa (job #18601)
Cod sursa(job #18601)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using std::sort;
#define FIN "amlei.in"
#define FOUT "amlei.out"
#define MAXE 500
#define MAXN 50
struct perm { int a[2]; };
typedef perm vec[MAXE];
vec A, B;
int n, t, u;
bool used[1<<16];
inline bool cmp(const perm &A, const perm &B)
{
int i;
for (i=1; A.a[i] == B.a[i] && i; --i) ;
return A.a[i] < B.a[i];
}
bool operator==(const perm &A, const perm &B)
{
return A.a[0] == B.a[0] && A.a[1] == B.a[1];
}
void rez()
{
sort(A, A+t, cmp); sort(B, B+u, cmp);
int i=0, j=0, ok = 1;
while (i<t && j<u)
{
if (! (A[i] == B[j])) { ok=0; break; }
while (++i<t && A[i] == A[i-1]) ;
while (++j<u && B[j] == B[j-1]) ;
}
if (i<t || j<u) ok = 0;
printf("%s\n", ok?"DA":"NU");
}
void citire()
{
int i, j, x;
freopen(FIN, "r", stdin);
freopen(FOUT,"w",stdout);
while (! feof(stdin))
{
memset(A, 0, sizeof(A));
memset(B, 0, sizeof(B));
scanf("%d %d %d\n", &n, &t, &u);
for (i=0; i<t; ++i)
for (j=0; j<n; ++j)
{
scanf("%d", &x);
A[i].a[abs(x)>>5] |= (x>0) << (x & 0x1f);
}
for (i=0; i<u; ++i)
for (j=0; j<n; ++j)
{
scanf("%d", &x);
B[i].a[abs(x)>>5] |= (x>0) << (x & 0x1f);
}
scanf("\n");
rez();
}
}
int main()
{
citire();
return 0;
}