SHARE
TWEET

Untitled

a guest Jan 21st, 2020 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Classes, sysutils
  10.   { you can add units after this };
  11. var
  12.   N, M, i, j, q, z, x, c, count : integer;
  13.   s : array of integer;
  14.   nots : array of Boolean;
  15.   t : array of Boolean;
  16.   Flag : Boolean;
  17.   Data : array of array of integer;
  18.   h, b, k : String;
  19.  
  20. begin
  21.   Assign(Input, 'disease.in');
  22.   Assign(Output, 'disease.out');
  23.   Reset(Input);
  24.   Rewrite(Output);
  25.  
  26.   Read(N, M);
  27.   SetLength(Data, M);
  28.   SetLength(nots, N);
  29.   SetLength(t, N);
  30.   SetLength(s, N);
  31.   for i := 0 to M - 1 do begin
  32.     SetLength(Data[i], N + 1);
  33.     for j := 0 to N do begin
  34.       Read(Data[i, j]);
  35.     end;
  36.  
  37.     for j := 0 to N - 1 do
  38.       if (Data[i, j] = 1) and (Data[i, N] = 0) and not nots[j]
  39.         then begin
  40.           nots[j] := True;
  41.           Inc(c);
  42.         end;
  43.   end;
  44.  
  45.   for i := 0 to M - 1 do begin
  46.     Count := 0;
  47.     if Data[i, N] = 0 then Continue;
  48.     for j := 0 to N - 1 do begin
  49.       if (Data[i, j] = 1) and not nots[j]
  50.         then begin Inc(count);
  51.           q := j;
  52.         end;
  53.     end;
  54.     if count = 0 then begin
  55.       WriteLn('Incorrect');
  56.       Exit;
  57.     end;
  58.     if (count = 1) and not t[q] then begin
  59.       t[q] := True;
  60.       Inc(z);
  61.     end;
  62.   end;
  63.  
  64.   Write(c, ' ');
  65.   for i :=0 to High(nots) do
  66.     if nots[i] then Write(i + 1, ' ' );
  67.  
  68.   WriteLn;
  69.  
  70.   Write(z, ' ');
  71.   for i := 0 to High(t) do begin
  72.     if t[i] then Write(i + 1, ' ');
  73.   end;
  74.  
  75.   WriteLn;
  76.   Write(N - z - c, ' ');
  77.   for i := 0 to N - 1 do
  78.     if not nots[i] and not t[i] then Write(i + 1, ' ');
  79.  
  80. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top