Pagini recente » Cod sursa (job #1792621) | Cod sursa (job #1359419) | Cod sursa (job #2047251) | Cod sursa (job #156161) | Cod sursa (job #2189476)
#include <fstream>
#include <vector>
using namespace std;
ifstream in("aprindere.in");
ofstream out("aprindere.out");
vector<char> rooms;
vector<pair<vector<int>, int> > switches;
int size, time_, switchnr;
int main(){
in>>size>>switchnr;
rooms.resize(size);
switches.resize(size);
for(int x = 0;x<size;x++){
in>>rooms[x];
rooms[x]-='0';
}
for(int x = 0, room, amount, aa;x<switchnr;x++){
in>>room>>aa>>amount;
switches[room].first.resize(amount);
switches[room].second = aa;
for(int y = 0;y<amount;y++){
in>>switches[room].first[y];
}
}
for(int x = 0;x<size;x++){
if(!rooms[x]){
for(int y = 0;y<switches[x].first.size();y++){
rooms[switches[x].first[y]] = rooms[switches[x].first[y]] ? 0 : 1;
}
time_+=switches[x].second;
}
}
out<<time_;
}