Pagini recente » Cod sursa (job #12187) | Cod sursa (job #1052661) | Cod sursa (job #1201980) | Cod sursa (job #37677) | Cod sursa (job #527995)
Cod sursa(job #527995)
#include <cstdio>
#include <bitset>
#include <algorithm>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pii pair< int,int >
#define T 510
#define N 55
int n,t,u;
bitset< N > poz[2][T];
bitset< N > neg[2][T];
bitset< T > are;
inline void citire() {
int x;
for(int i=0; i<t; ++i) {
for(int j=0; j<n; ++j) {
scanf("%d",&x);
if(x>0)
poz[0][i].set(x);
else
neg[0][i].set(-x);
}
}
for(int i=0; i<u; ++i) {
for(int j=0; j<n; ++j) {
scanf("%d",&x);
if(x>0)
poz[1][i].set(x);
else
neg[1][i].set(-x);
}
}
}
inline bool rezolva() {
bool gasit;
for(int i=0; i<t; ++i) {
gasit = false;
for(int j=0; j<u; ++j) {
if(poz[0][i]==poz[1][j] && neg[0][i]==neg[1][j]) {
gasit = true;
are[j] = 1;
}
}
if(gasit==false)
return false;
}
for(int i=0; i<u; ++i) {
if(!are[i])
return false;
}
return true;
}
inline void refresh() {
for(int i=0; i<t; ++i) {
poz[0][i].reset();
neg[0][i].reset();
}
for(int i=0; i<u; ++i) {
poz[1][i].reset();
neg[1][i].reset();
}
}
int main() {
freopen("amlei.in","r",stdin);
freopen("amlei.out","w",stdout);
while(scanf("%d%d%d",&n,&t,&u)!=EOF) {
citire();
if(rezolva())
fputs("DA\n",stdout);
else
fputs("NU\n",stdout);
refresh();
}
return 0;
}