Program Necklace;
Var s:ansistring;
i,j,k,max,n,t:longint;
l,r:char;
fi,fj:boolean;
Begin
readln(n);
readln(s);
s:=s+s;
max:=0;
for k:=1 to n do
begin
i:=k;j:=k+n-1;t:=0;
l:=s[j];r:=s[i];
fi:=true;fj:=true;
while i<=j do
begin
if fi then
if (s[i]=r)or(s[i]='w') then
begin
inc(i);inc(t);
end
else fi:=false;
if fj then
if (s[j]=l)or(s[j]='w') then
begin
dec(j);inc(t);
end
else fj:=false;
if (i=j)and((s[i]=r)or(s[j]=l))and fi and fj then
begin
inc(t);break;
end;
if ord(fi)+ord(fj)=0 then break;
end;
if t>max then max:=t;
end;
writeln(max);
End.
测试结果1: 通过本测试点|有效耗时172ms
测试结果2: 通过本测试点|有效耗时47ms
测试结果3: 测试结果错误.错误结果为:72
正确结果应为:74
测试结果4: 通过本测试点|有效耗时62ms
测试结果5: 通过本测试点|有效耗时47ms
测试结果6: 通过本测试点|有效耗时47ms
测试结果7: 通过本测试点|有效耗时47ms
测试结果8: 通过本测试点|有效耗时47ms
测试结果9: 通过本测试点|有效耗时46ms
测试结果10: 通过本测试点|有效耗时47ms