Cod sursa(job #2445336)

Utilizator florin_salamFlorin Salam florin_salam Data 3 august 2019 17:38:03
Problema Amlei Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.13 kb
#include <fstream>
#include <map>

using namespace std;

int main()
{
    ifstream fin("amlei.in");
    ofstream fout("amlei.out");
    int n, t, u;
    while (fin >> n >> t >> u)
    {
        map <long long, bool> vals1, vals2;
        for (int i = 1;i <= t;++i)
        {
            long long val = 0;
            for (int j = 1;j <= n;++j)
            {
                int x;
                fin >> x;
                if (x > 0)
                    val |= (1LL << x);
            }
            vals1[val] = true;
        }
        for (int i = 1;i <= u;++i)
        {
            long long val = 0;
            for (int j = 1;j <= n;++j)
            {
                int x;
                fin >> x;
                if (x > 0)
                    val |= (1LL << x);
            }
            vals2[val] = true;
        }
        bool good = true;
        for (auto &x : vals1)
            if (vals2.find(x.first) == vals2.end())
                good = false;
        if (good)
            fout << "DA\n";
        else
            fout << "NU\n";
    }
    fin.close();
    fout.close();
    return 0;
}