暴力模拟无算法
Program P1868;
Var
c:char;
n,i,j,k:longint;
a:array[0..10000] of longint;
function is_ant:boolean;
var
i,j,k:longint;
begin
for k:=1 to n shr 2 do
for i:=1 to n-k shl 1-1 do
if ((a[i]<a[i+k]) and (a[i+k]<a[i+2*k])) or ((a[i]>a[i+k]) and (a[i+k]>a[i+2*k])) then exit(false);
exit(true);
end;
Begin
while true do
begin
read(c);
if c='0' then break;
val(c,n);
repeat
read(c);
if c=':' then break;
n:=n*10+ord(c)-48;
until false;
for i:=1 to n do
begin
read(j);
a[j]:=i;
end;
if is_ant then writeln('yes') else writeln('no');
readln;
end;
end.