9 procedure checkRange(v: string; value, a, b: integer);
\r
11 if (value < a) or (value > b) then begin
\r
12 quit(_wa, format('%s not in range %d..%d: %d', [v, value, a, b]));
\r
16 function get(line: string; field: longint): string;
\r
22 while (field > 0) do begin
\r
24 while (line[pos] <> ',') do begin
\r
25 result := result + line[pos];
\r
36 r1, r2, c1, c2: integer;
\r
38 data: array [1..max_n] of string;
\r
41 n := inf.readLongint();
\r
42 m := inf.readLongint();
\r
44 for i := 1 to n do begin
\r
45 data[i] := inf.readString();
\r
48 ja := ans.readWord(blanks, blanks);
\r
49 pa := ouf.readWord(blanks, blanks);
\r
51 if (pa = 'NO') then begin
\r
52 r1 := ouf.readLongint();
\r
53 r2 := ouf.readLongint();
\r
54 c1 := ouf.readLongint();
\r
55 c2 := ouf.readLongint();
\r
57 checkRange('r1', r1, 1, n);
\r
58 checkRange('r2', r2, 1, n);
\r
59 checkRange('c1', c1, 1, m);
\r
60 checkRange('c2', c2, 1, m);
\r
62 if (r1 = r2) then begin
\r
63 quit(_wa, format('r1 = r2 = %d', [r1]));
\r
65 if (c1 = c2) then begin
\r
66 quit(_wa, format('c1 = c2 = %d', [c1]));
\r
69 if (get(data[r1], c1) <> get(data[r2], c1)) then begin
\r
70 quit(_wa, format('Values in first column %d in rows %d and %d does not match', [c1, r1, r2]));
\r
72 if (get(data[r1], c2) <> get(data[r2], c2)) then begin
\r
73 quit(_wa, format('Values in second column %d in rows %d and %d does not match', [c2, r1, r2]));
\r
75 if (ja = 'YES') then begin
\r
76 quit(_fail, format('Solution r1 = %d, r2 = %d, c1 = %d, c2 = %d missed by the Jury', [r1, r2, c1, c2]));
\r
78 quit(_ok, format('r1 = %d, r2 = %d, c1 = %d, c2 = %d', [r1, r2, c1, c2]));
\r
81 if (pa = 'YES') then begin
\r
82 if (ja = 'NO') then begin
\r
83 r1 := ans.readLongint();
\r
84 r2 := ans.readLongint();
\r
85 c1 := ans.readLongint();
\r
86 c2 := ans.readLongint();
\r
87 quit(_wa, format('Solution r1 = %d, r2 = %d, c1 = %d, c2 = %d missed', [r1, r2, c1, c2]));
\r
91 quit(_wa, format('YES or NO expected, %s found', [pa]));
\r