Cod sursa(job #1074163)
Utilizator | Data | 7 ianuarie 2014 12:16:38 | |
---|---|---|---|
Problema | Balanta | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.81 kb |
#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;
}