Pagini recente » Cod sursa (job #2788141) | Cod sursa (job #3171852) | Cod sursa (job #2249039) | Cod sursa (job #1510428) | Cod sursa (job #2037185)
#include <iostream>
#include <fstream>
#include <bitset>
using namespace std;
ifstream in("aprindere.in");
ofstream out("aprindere.out");
const int NMAX = 1000;
const int DIM = 1000000;
int n, m, res, pos;
bitset <1 + NMAX> ap;
char buff[DIM];
void read(int &no){
no = 0;
while(!isdigit(buff[pos])){
if(++pos == DIM){
in.read(buff, DIM);
pos = 0;
}
}
while(isdigit(buff[pos])){
no = (no * 10) + (buff[pos] - '0');
if(++pos == DIM){
in.read(buff, DIM);
pos = 0;
}
}
}
int main()
{
in.read(buff, DIM);
//in >> n >> m;
read(n);
read(m);
for(int i = 0; i < n; i++) {
int light;
//in >> light;
read(light);
ap[i] = light;
}
for(int i = 1; i <= m; i++) {
int room, time, no;
//in >> room >> time >> no;
read(room);
read(time);
read(no);
if(ap[room] == 0) {
res += time;
for(int j = 1; j <= no; j++) {
int x;
//in >> x;
read(x);
ap[x] = 1 - ap[x];
}
} else {
for(int j = 1; j <= no; j++) {
int x;
//in >> x;
read(x);
}
}
}
out << res << '\n';
in.close();
out.close();
return 0;
}