|
|
вернуться в форумWho solved problem1054,can you give me a example whose solution is "IMPOSSIBLE" or there is no such example? Послано Tests 16 июн 2001 10:47 yeah, this case is impossible :"> 2 2 1 Good luck ! QH@ Could you help me to find what's wrong,it my comprehesion right? Послано Roger 18 июн 2001 20:12 const maxN = 100; pred : array[1..3]of longint = (3,1,2); succ : array[1..3]of longint = (2,3,1); var now,tar : array[0..maxN]of longint; ans,n : longint; procedure Move(v,whi : longint); var i,j,middle : longint; begin if whi=pred[now[v]] then middle:=succ[now[v]] else middle:=pred[now[v]]; for i:=v-1 downto 1 do if now[i]<>middle then Move(i,middle); ans:=ans+1; now[v]:=whi; end; var i : integer; begin read(n); for i:=1 to N do begin read(tar[i]); now[i]:=1; end; for i:=n downto 1 do if tar[i]<>now[i] then Move(i,tar[i]); writeln(ans); end. Do you mean the answer of "2 2 1" is "no solution"? Послано Roger 19 июн 2001 18:22 > 2 > 2 > 1 > > Good luck ! > > QH@ I think the answer is 3! 1 2 --> 2 --> --> 1 3 empty empty 3 empty 1 3 2 1 3 2 empty What wrong with the answer? Is my comprehesion wrong? Re: Do you mean the answer of > > 2 > > 2 > > 1 > > > > Good luck ! > > > > QH@ > > I think the answer is 3! > 1 > 2 --> 2 --> --> 1 > 3 empty empty 3 empty 1 3 2 1 3 2 empty > > What wrong with the answer? Is my comprehesion wrong? > your comprehesion is wrong. because you don't use the optimal agoriythm Re: Do you mean the answer of > > 2 > > 2 > > 1 > > > > Good luck ! > > > > QH@ > > I think the answer is 3! > 1 > 2 --> 2 --> --> 1 > 3 empty empty 3 empty 1 3 2 1 3 2 empty > > What wrong with the answer? Is my comprehesion wrong? > your comprehesion is wrong. because you don't use the optimal agoriythm |
|
|