Pagini recente » Istoria paginii utilizator/deehoroejkoli | Profil MKLOL | Profil the1dragon | xorseq | Cod sursa (job #1551040)
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
freopen("balanta.in", "r", stdin);
freopen("balanta.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
bool valid[1025];
for(int i = 1; i < 1025; i ++)
valid[i] = 1;
int n, m, q, ban[1025], x;
cin >> n >> m;
for(int i = 0; i < m; i ++)
{
cin >> q;
for(int j = 0; j < n; j ++)
ban[j] = 0;
for(int j = 0; j < q; j ++)
{
cin >> x;
ban[x] = 1;
}
for(int j = 0; j < q; j ++)
{
cin >> x;
ban[x] = 2;
}
cin >> x;
if(x == 0)
{
for(int j = 0; j < n; j ++)
{
if(ban[j])
valid[j] = 0;
}
}
if(x == 1)
{
for(int j = 0; j < n; j ++)
{
if(ban[j] == 2)
valid[j] = 0;
}
}
if(x == 2)
{
for(int j = 0; j < n; j ++)
{
if(ban[j] == 1)
valid[j] = 0;
}
}
}
int nr = 0, poz, i = 0;
while(nr < 2 && i <= n)
{
if(valid[i])
{
nr ++;
poz = i;
}
i ++;
}
for(int i = 0; i <= n; i ++)
cout << valid[i] << " ";
cout << endl;
if(nr == 1)
cout << poz;
else cout << 0;
return 0;
}