Pagini recente » Cod sursa (job #2236414) | Cod sursa (job #2446200) | Cod sursa (job #1812678) | Cod sursa (job #484319) | Cod sursa (job #2585166)
#include <fstream>
#include <bitset>
using namespace std;
bitset<1025>result;
bitset<1025>result1;
bitset<1025>left1;
bitset<1025>right1;
int v[1025],v1[1025];
int main()
{
ifstream cin("balanta.in");
ofstream cout("balanta.out");
for(int i=1;i<=1024;i++)
{
result[i]=0;
result1[i]=0;
}
int n,k,l,comp,a,ok=0;
cin>>n>>k;
for(int i=1;i<=n;i++)
{
result[i]=1;
result1[i]=1;
}
for(int i=0;i<k;i++)
{
for(int j=1;j<=n;j++)
{
right1[j]=left1[j]=0;
}
cin>>l;
for(int j=0;j<l;j++)
{
cin>>a;
v[j]=a;
left1[a]=1;
}
for(int j=0;j<l;j++)
{
cin>>a;
v1[j]=a;
right1[a]=1;
}
cin>>comp;
if(comp==1)
{
for(int j=0;j<l;j++)
{
result[v1[j]]=0;
result1[v[j]]=0;
}
}
else if(comp==2)
{
for(int j=0;j<l;j++)
{
result[v[j]]=0;
result1[v1[j]]=0;
}
}
else if(comp==0)
{
for(int j=0;j<l;j++)
{
result[v[j]]=0;
result1[v[j]]=0;
}
for(int j=0;j<l;j++)
{
result[v1[j]]=0;
result1[v1[j]]=0;
}
}
if(result.count()==1)
{
ok=1;
break;
}
else if(result1.count()==1)
{
ok=2;
break;
}
}
if(ok==0)
{
cout<<"0"<<endl;
}
else if(ok==1)
{
for(int i=1;i<=n;i++)
{
if(result[i]==1)
{
cout<<i<<endl;
break;
}
}
}
else if(ok==2)
{
for(int i=1;i<=n;i++)
{
if(result1[i]==1)
{
cout<<i<<endl;
break;
}
}
}
return 0;
}