ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1023. Buttons

Why it does not work?
Posted by Ovchinnikov Georg 12 Apr 2003 17:45
program permutation;
var
m,p : array [1..1000] of word;
N,i,j : integer;
k : longint;
quit : boolean;
Begin
  readln(N);
  for i := 1 to N do
   read(p[i]);
  for i := 1 to n do
   m[i]:=p[i];
  k:=1;
  quit := false;
  while true do begin
   j:=0;
   repeat
    j:=j+1;
    quit := m[j]=j;
   until (quit=false) or ((i=n) and (m[i]=i));
   if quit then break;
   k:=k+1;
   for i := 1 to n do
    m[i] := p[m[i]];
  end;
  writeln(K);
end.
It is wrong solution (+)
Posted by Ilia S. Chm (Spb SU) 12 Apr 2003 21:56