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 1054. Tower of Hanoi

Who solved problem1054,can you give me a example whose solution is "IMPOSSIBLE" or there is no such example?
Posted by Tests 16 Jun 2001 10:47
yeah, this case is impossible :">
Posted by Dinh Quang Hiep (mg9h@yahoo.com) 16 Jun 2001 11:53
2
2
1

Good luck !

QH@
Could you help me to find what's wrong,it my comprehesion right?
Posted by Roger 18 Jun 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"?
Posted by Roger 19 Jun 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
Posted by Chen Xiaoke 1 Feb 2002 19:25
> > 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
Posted by Chen Xiaoke 1 Feb 2002 19:25
> > 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