Cod sursa(job #1481878)

Utilizator Dragne.Andrei11Dragne Andrei Dragne.Andrei11 Data 5 septembrie 2015 14:07:59
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <cstdio>
#define nmax 1001

using namespace std;

struct numere
{
    bool b;
    short c, tc, nrc;
    short vec[101];
};
numere v[nmax];
int main()
{
    freopen("aprindere.in", "r", stdin);
    freopen("aprindere.out", "w", stdout);
    short n, m;
    int s=0;
    bool bb;

    scanf("%hd%hd", &n, &m);
    for(register short i=1;i<=n;i++)
        scanf("%d", &v[i].b);
    for(register short i=1;i<=m;i++)
    {
        scanf("%hd%hd%hd", &v[i].c, &v[i].tc, &v[i].nrc);
        v[i].c++;
        if(v[v[i].c].b==0)
        {
            for(register short j=1;j<=v[i].nrc;j++)
            {
                scanf("%hd", &v[i].vec[j]);
                v[i].vec[j]++;
                v[v[i].vec[j]].b=1-v[v[i].vec[j]].b;
            }
            s+=v[i].tc;
        }
        else
            for(register short j=1;j<=v[i].nrc;j++)
                scanf("%hd", &v[i].vec[j]);
    }
    printf("%d\n", s);


    return 0;
}