Pagini recente » Cod sursa (job #1352113) | Cod sursa (job #228562) | Cod sursa (job #1082054) | Cod sursa (job #2388248) | Cod sursa (job #1074163)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("balanta.in");
ofstream fout("balanta.out");
int n, m, temp1, temp2, p = 0;
fin>>n>>m;
bool arr[n];
for(int i=0; i< n; i++)
{
arr[i] = 0;
}
int temp[n];
for(int i =0; i< m; i++)
{
fin>>temp1;
for(int j=0; j< 2*temp1; j++)
{
fin>>temp[j];
}
fin>>temp2;
if(temp2 != 0)
{
if(temp2 == 1)
{
for(int j=0; j< temp1; j++)
{
arr[temp[j] - 1]= 1;
}
for(int j=temp1; j< 2*temp1; j++)
{
arr[temp[j] - 1]= 0;
}
}
else if(temp2 == 2)
{
for(int j=temp1; j< 2*temp1; j++)
{
arr[temp[j] - 1]= 1;
}
for(int j=0; j< temp1; j++)
{
arr[temp[j] - 1]= 0;
}
}
}
}
for(int i=0; i< n; i++)
{
if(i == 0)
{
if(arr[i] == 1 && arr[i+1] == 0) p = i+1;
}
else if(i == n-1)
{
if(arr[i] == 1 && arr[i-1] == 0) p = i+1;
}
else if(arr[i] == 1 && arr[i-1] == 0 && arr[i+1] == 0) p = i+1;
}
fout<<p<<endl;
return 0;
}