|
|
back to boardHow to find impossible sequense I've written program that finds the number of steps but Can't determine whether it's possible or not. var N:integer; s,d:array[1..31] of integer; i,j,t:integer; K:longint; n2:array[0..30] of longint; begin readln(N); for I:=1 to n do read(s[i]); n2[0]:=1; for I:=1 to 30 do n2[i]:=n2[i-1]*2; for I:=1 to n do d[i]:=1; k:=0; for I:=n downto 1 do begin IF D[I]<>S[I] then begin K:=K+N2[i-1]; for j:=1 to 3 do if (s[i]<>j) and (d[i]<>j) then begin t:=j; break; end; for J:=1 to i-1 do if d[j]=d[i] then begin d[j]:=t; end; d[i]:=s[i]; end; end; writeln(k);
end. |
|
|