Cod sursa(job #1077178)

Utilizator narcis_vsGemene Narcis - Gabriel narcis_vs Data 10 ianuarie 2014 22:44:59
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <fstream>
#include <vector>
using namespace std ;
const int Nmax = 1002;
vector < int > List[Nmax];
bool v[Nmax];
int Cost[Nmax];
int main()
{
    int i ,x , n, m, cost , room ,cnt ,Sol = 0;    
    ifstream f("aprindere.in");
    f >> n >> m;
    for(i = 0;i < n; ++i)
        f >> v[i];
    while(m--)
    {
        f >> room >>  cost >> cnt;
        Cost[room] = cost;
        while(cnt--)
        {
            f >> x;
            List[room].push_back(x);
        }
    }
    f.close();
    for(i = 0;i < n; ++i)
        if(v[i]==0)
        {
            Sol += Cost[i];
            for(vector < int > ::iterator it = List[i].begin(); it != List[i].end(); ++it)
                v[*it] = v[*it]^1;
        }
    ofstream g("aprindere.out");
    g<<Sol<<"\n";
    g.close();
    return 0;
}