MCITYHAL - Repair City Hall
Tác giả: ladpro98
Ngôn ngữ: Pascal
program mcityhall;
uses math;
const fi='';
maxN=222;
var a:array[0..maxN,0..maxN] of longint;
res:array[1..maxN] of longint;
m,n:longint;
procedure input;
var f:text;
i,j:longint;
c:char;
begin
assign(f,fi);
reset(f);
readln(f,m,n);
for i:=1 to m do
begin
for j:=1 to n do
begin
read(f,c);
if c='1' then a[i,j]:=1
else
a[i,j]:=0;
end;
readln(f);
end;
close(f);
end;
procedure init;
var i:longint;
begin
for i:=1 to n do
a[m+1,i]:=1;
end;
procedure process;
var i,j,k:longint;
begin
for j:=1 to n do
begin
i:=1;
while i<=m do
begin
while (i<=m) and (a[i,j]=1) do inc(i);
if i>m then break;
k:=i+1;
while a[k,j]=0 do inc(k);
inc(res[k-i]);
i:=k;
end;
end;
end;
procedure output;
var I:LONGINT;
begin
for i:=1 to m do
begin
if res[i]>0 then
writeln(i,' ',res[i]);
end;
end;
begin
input;
init;
process;
output;
end.