Pagini recente » template/ixia-winner | Cod sursa (job #2305583) | Cod sursa (job #841004) | Cod sursa (job #703603) | Cod sursa (job #738478)
Cod sursa(job #738478)
Program aprindere;
var a,c:array [0..1000] of byte;
aux:array [0..1000,0..105] of longint;
i,j,n,m,sol,x,nr,cost:longint;
fi,fo:text;
procedure solve;
begin
nr:=aux[i,0]; sol:=sol+c[i];
for j:=1 to nr do
if a[aux[i,j]]=0 then a[aux[i,j]]:=1 else a[aux[i,j]]:=0;
end;
begin
assign(fi,'aprindere.in');
assign(fo,'aprindere.out');
reset(fi); rewrite(fo);
readln(fi,n,m);
for i:=0 to n-1 do read(fi,a[i]);
readln(fi);
for i:=1 to m do begin
read(fi,x,cost,nr); c[x]:=cost; aux[x,0]:=nr;
for j:=1 to nr do read(fi,aux[x,j]); readln(fi);
end;
for i:=0 to n do
if a[i]=0 then solve;
write(fo,sol);
close(fo);
end.