MCITYHAL - Repair City Hall
Tác giả: ll931110
Ngôn ngữ: Pascal
{$MODE DELPHI}
Program MCITYHAL;
Const
input = '';
output = '';
max = 200;
Var
c: array[1..max,1..max] of boolean;
a: array[1..max] of integer;
n,m: integer;
Procedure init;
Var
f: text;
i,j: integer;
ch: char;
Begin
Assign(f, input);
Reset(f);
Readln(f, m, n);
For i:= 1 to m do
Begin
For j:= 1 to n do
Begin
Read(f, ch);
If ch = '1' then c[i,j]:= true else c[i,j]:= false;
End;
Readln(f);
End;
Close(f);
End;
Procedure solve;
Var
current,i,j: integer;
Begin
Fillchar(a, sizeof(a), 0);
current:= 0;
For j:= 1 to n do
Begin
For i:= 1 to m do if not c[i,j] then inc(current)
else if current <> 0 then
Begin
inc(a[current]);
current:= 0;
End;
If current <> 0 then
Begin
inc(a[current]);
current:= 0;
End;
End;
End;
Procedure printresult;
Var
f: text;
i: integer;
Begin
Assign(f, output);
Rewrite(f);
For i:= 1 to max do
if a[i] <> 0 then writeln(f, i, ' ', a[i]);
Close(f);
End;
Begin
init;
solve;
printresult;
End.