fork download
  1. program binaryrectangle;
  2. Uses Math;
  3.  
  4. const
  5. MAXN = 1000;
  6.  
  7. var
  8. M, N, T, ans, i, j, test, infx, infy, supx, supy, count : LongInt;
  9. line : Array[0..MAXN-1,0..MAXN-1] of integer;
  10.  
  11. begin
  12. {
  13.   uncomment the two following lines if you want to read/write from files
  14.   assign(input, 'input.txt'); reset(input);
  15.   assign(output, 'output.txt'); rewrite(output);
  16. }
  17.  
  18. ReadLn(T);
  19.  
  20. ReadLn(N, M);
  21. count:=0; infx:=N; infy:=M; supx:=-1; supy:=-1;
  22. for i:=0 to N-1 do begin
  23. for j:=0 to M-1 do Readln(line[i,j]);
  24.  
  25. end;
  26.  
  27.  
  28. for i:=0 to N-1 do
  29. begin
  30. for j:=0 to M-1 do
  31. write(line[i,j],' ');
  32. writeln;
  33. end; end.
  34. ans := 0;
  35. if ((count <> 0) and ((supx - infx + 1) * (supy - infy + 1) = count)) then ans:=1
  36. else ans:=0;
  37.  
  38. WriteLn(ans);
  39. end;
  40. end.
  41.  
Success #stdin #stdout 0.01s 5284KB
stdin
1
5 5
00000
00110
00110
00110
00000
stdout
0 110 110 110 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0