| 比赛 | NOIP模拟赛by mzx Day2 | 评测结果 | WATTTTTTTT |
|---|---|---|---|
| 题目名称 | 拯救紫萱学姐 | 最终得分 | 10 |
| 用户昵称 | 燕哥到此一游 | 运行时间 | 8.191 s |
| 代码语言 | Pascal | 内存使用 | 0.15 MiB |
| 提交时间 | 2016-10-20 21:55:39 | ||
program fuckyoupentuple;
var
fin,fout:text;
st,st1,st2:string;
i,j,sum,max,min,len:longint;
procedure cut(s1,s2:string);
var
o,p,m,len1,len2:longint;
stt1,stt2:string;
begin
len1:=length(s1);
len2:=length(s2);
for o:=0 to len1 do
begin
stt1:=copy(st1,1,o);
{ if stt1=copy(st1,len1-o+1,o) then
begin }
for p:=0 to len2 do
begin
stt2:=copy(st2,1,p);
if (stt1=copy(st1,len1-o+1,o)) and (stt2=copy(st2,len2-p+1,p)) then
begin
if stt1=stt2 then
begin
sum:=sum+sqr((len1-length(stt1)))+sqr((len2-length(stt2)));
if sum<min
then min:=sum;
if (stt1<>'') or (stt2<>'')
then m:=0
else if (stt1<>'') and (stt2<>'')
then
begin
cut(stt1,stt2);
end;
if sum<min
then min:=sum;
end
else
begin
if (stt1<>'') or (stt2<>'')
then m:=0
else if (stt1<>'') and (stt2<>'')
then
begin
cut(stt1,stt2);
end;
if sum<min
then min:=sum;
end;
end;
end;
end;
end;
begin
assign(fin,'savemzx.in');
assign(fout,'savemzx.out');
reset(fin);
rewrite(fout);
readln(fin,st);
len:=length(st);
max:=0;
for i:=1 to len do
begin
st1:=copy(st,1,i);
for j:=i+1 to len do
begin
st2:=copy(st,1,j);
min:=maxlongint;
sum:=0;
cut(st1,st2);
if min>max
then max:=min;
end;
end;
writeln(fout,max);
close(fin);
close(fout);
end.