📄 ac1065.pas
字号:
program tju1065;
const
maxn=100000;
maxl=50;
var
w:array[0..maxn]of string[maxl];
s,l:array[0..maxl]of longint;
n,i,t,ans:longint;
procedure qsort(s,t:longint);
var
p,i,j:longint;
tmp:string;
begin
if s>=t then exit;
p:=s+random(t-s+1);
tmp:=w[p];w[p]:=w[s];
i:=s;j:=t;
repeat
while (i<j) and (w[j]>tmp) do dec(j);
if i=j then break;w[i]:=w[j];inc(i);
while (i<j) and (w[i]<tmp) do inc(i);
if i=j then break;w[j]:=w[i];dec(j);
until i=j;
w[i]:=tmp;
qsort(s,i-1);
qsort(i+1,t);
end;
begin
repeat
readln(n);
for i:=1 to n do
readln(w[i]);
qsort(1,n);
ans:=0;t:=0;
for i:=1 to n do begin
while w[s[t]]<>copy(w[i],1,length(w[s[t]])) do dec(t);
if w[s[t]]=w[i] then
inc(l[t])
else begin
inc(t);s[t]:=i;l[t]:=l[t-1]+1;
end;
if l[t]>ans then ans:=l[t];
end;
writeln(ans);
until seekeof;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -