Pagini recente » Cod sursa (job #2462105) | Cod sursa (job #3199269) | Cod sursa (job #912016) | Cod sursa (job #896092) | Cod sursa (job #2737652)
#include <bits/stdc++.h>
using namespace std;
#ifndef LOCAL
ifstream in("balanta.in");
ofstream out("balanta.out");
#define cin in
#define cout out
#endif //LOCAL
const int NMAX = 1024 + 16;
bitset<NMAX> possible[2];
int main()
{
int n, m; cin >> n >> m;
for(int i = 1; i <= n; i++)
{
possible[0][i] = 1;
possible[1][i] = 1;
}
for(int i = 0; i < m; i++)
{
int k; cin >> k;
vector<int> l(k), r(k);
for(auto& e : l) cin >> e;
for(auto& e : r) cin >> e;
int q; cin >> q;
if(q == 0)
{
bitset<NMAX> cntMask;
for(auto e : l)
cntMask[e] = 1;
for(auto e : r)
cntMask[e] = 1;
cntMask = ~cntMask;
possible[0] &= cntMask;
possible[1] &= cntMask;
}
if(q == 1)
{
bitset<NMAX> cntMask1;
for(auto e : l)
cntMask1[e] = 1;
bitset<NMAX> cntMask0;
for(auto e : r)
cntMask0[e] = 1;
possible[0] &= cntMask0;
possible[1] &= cntMask1;
}
if(q == 2)
{
bitset<NMAX> cntMask0;
for(auto e : l)
cntMask0[e] = 1;
bitset<NMAX> cntMask1;
for(auto e : r)
cntMask1[e] = 1;
possible[0] &= cntMask0;
possible[1] &= cntMask1;
}
}
#ifdef LOCAL
for(int i = 1; i <= n; i++)
{
if(possible[0][i]) cout << "A" << i << endl;
if(possible[1][i]) cout << "B" << i << endl;
}
#endif //LOCAL
bitset<NMAX> both = possible[0] | possible[1];
if(both.count() != 1)
cout << 0 << endl;
else
for(int i = 1; i <= n; i++)
if(both[i] == 1)
cout << i << endl;
return 0;
}