Pagini recente » Cod sursa (job #2229752) | Cod sursa (job #1070572) | Cod sursa (job #292659) | Cod sursa (job #2692637) | Cod sursa (job #2577503)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("balanta.in");
ofstream cout("balanta.out");
int v[1030],v2[1030],v3[1030];
int main()
{
int n,m,k,a,nr,nr2,cnt = 0;
cin>>n>>m;
for(int x = 0;x < m;x++){
cin>>k;
for(int y = 0;y < k;y++){
cin>>a;
v[a] = 1;
}
for(int y = 0;y < k;y++){
cin>>a;
v2[a] = 1;
}
cin>>nr;
if(nr == 0){
for(int y = 1;y <= n;y++){
if(v[y] > 0 || v2[y] > 0){
v3[y] = 1;
}
}
}else if(nr == 1){
for(int y = 1;y <= n;y++){
if(v[y] != 1){
v3[y] = 1;
}
}
}else{
for(int y = 1;y <= n;y++){
if(v2[y] != 1){
v3[y] = 1;
}
}
}
for(int y = 1;y <= n;y++){
v[y] = 0;
v2[y] = 0;
}
}
for(int x = 1;x <= n;x++){
if(v3[x] == 0){
nr2 = x;
cnt++;
}
}
if(cnt == 1){
cout<<nr2;
}else cout<<0;
return 0;
}