Cod sursa(job #2006671)

Utilizator stefdascalescuStefan Dascalescu stefdascalescu Data 31 iulie 2017 11:26:06
Problema Balanta Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
#include<bits/stdc++.h>
using namespace std;
ifstream f("balanta.in");
ofstream g("balanta.out");
int n,m;
bool v[1050];
int nrf,mn,l,r;
int v1[1050];
int main()
{
    f>>n>>m;
    memset(v,1,n+1);
    for(int i=1;i<=m;++i)
    {
        f>>l;
        for(int j=1;j<=l+l;++j)
            f>>v1[j];
        f>>r;
        if(r==0)
            for(int j=1;j<=l+l;++j)
                v[v1[j]]=0;
        if(r==1)
            for(int j=l+1;j<=l+l;++j)
                v[v1[j]]=0;
        if(r==2)
            for(int j=1;j<=l;++j)
                v[v1[j]]=0;
    }
    for(int i=1;i<=n;++i)
        if(v[i]==1)
            ++nrf,mn=i;
    if(nrf==1)
        g<<mn;
    else
        g<<0;
    return 0;
}