about summary refs log tree commit diff
path: root/others/volume1/071.pas
blob: 59191daaa75095e47cb0d8cb7f3c044cfd6e3303 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{$mode objfpc}
uses math, clib;

var
  n, m, i, j: int16;
  (* For math compatibility *)
  a: array of array of integer;
  res: array of integer;
  (* For clib compatibility *)
  rowmin: array of int64;
  colmax: int64;

begin
  readln(n, m);
  setlength(a, n);
  setlength(rowmin, n);
  for i := 0 to n - 1 do
    begin
      setlength(a[i], m);
      for j := 0 to m - 1 do
        read(a[i][j]);
      rowmin[i] := minvalue(a[i])
    end;
  qsort(rowmin);
  setlength(res, 0);
  for j := 0 to m - 1 do
    begin
      colmax := a[0][j];
      for i := 1 to n - 1 do
        if a[i][j] > colmax then
          colmax := a[i][j];
      if bsearch(rowmin, colmax) > -1 then
        begin
          setlength(res, length(res) + 1);
          res[length(res) - 1] := colmax
        end
    end;
  writeln(length(res));
  for i in res do
    write(i, ' ');
  writeln
end.