Cod sursa(job #2182236)

Utilizator StarGold2Emanuel Nrx StarGold2 Data 22 martie 2018 11:25:06
Problema Amlei Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.02 kb
#include <bits/stdc++.h>
using namespace std;

ifstream in("amlei.in");
ofstream out("amlei.out");

set<long long> mst1, mst2;

int main(void) {
    for (int n, p, q; in >> n >> p >> q; ) {
        mst1.clear();
        for (int i = 1; i <= p; ++i) {
            long long x = 0;
            for (int j = 1; j <= n; ++j) {
                int aux;
                in >> aux;

                if (aux > 0)
                    x |= (1LL << aux);
            }
            mst1.insert(x);
        }

        mst2.clear();
        for (int i = 1; i <= q; ++i) {
            long long x = 0;
            for (int j = 1; j <= n; ++j) {
                int aux;
                in >> aux;

                if (aux > 0)
                    x |= (1LL << aux);
            }
            mst2.insert(x);
        }

        bool ok = true;
        for (long long x : mst1)
            if (mst2.find(x) == mst2.end())
                ok = false;
        out << (ok ? "DA\n" : "NU\n");
    }

    return 0;
}