Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program project1;
- {$mode objfpc}{$H+}
- uses
- {$IFDEF UNIX}{$IFDEF UseCThreads}
- cthreads,
- {$ENDIF}{$ENDIF}
- Classes, sysutils
- { you can add units after this };
- var
- N, M, i, j, q, z, x, c, count : integer;
- s : array of integer;
- nots : array of Boolean;
- t : array of Boolean;
- Flag : Boolean;
- Data : array of array of integer;
- h, b, k : String;
- begin
- Assign(Input, 'disease.in');
- Assign(Output, 'disease.out');
- Reset(Input);
- Rewrite(Output);
- Read(N, M);
- SetLength(Data, M);
- SetLength(nots, N);
- SetLength(t, N);
- SetLength(s, N);
- for i := 0 to M - 1 do begin
- SetLength(Data[i], N + 1);
- for j := 0 to N do begin
- Read(Data[i, j]);
- end;
- for j := 0 to N - 1 do
- if (Data[i, j] = 1) and (Data[i, N] = 0) and not nots[j]
- then begin
- nots[j] := True;
- Inc(c);
- end;
- end;
- for i := 0 to M - 1 do begin
- Count := 0;
- if Data[i, N] = 0 then Continue;
- for j := 0 to N - 1 do begin
- if (Data[i, j] = 1) and not nots[j]
- then begin Inc(count);
- q := j;
- end;
- end;
- if count = 0 then begin
- WriteLn('Incorrect');
- Exit;
- end;
- if (count = 1) and not t[q] then begin
- t[q] := True;
- Inc(z);
- end;
- end;
- Write(c, ' ');
- for i :=0 to High(nots) do
- if nots[i] then Write(i + 1, ' ' );
- WriteLn;
- Write(z, ' ');
- for i := 0 to High(t) do begin
- if t[i] then Write(i + 1, ' ');
- end;
- WriteLn;
- Write(N - z - c, ' ');
- for i := 0 to N - 1 do
- if not nots[i] and not t[i] then Write(i + 1, ' ');
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement