|
|
вернуться в форумI had WA on test #2. Why did it happened? Help me, please. Послано $T.MAX 5 авг 2005 20:02 Here's my code: (I looked for the walls like as mirrors) {H+}{N+} .Program N1258; . .var . w,d :integer; . x1,x0,y1,y0 :integer; . way :string; . leng :integer; . BF,LR :integer; . hor,ver :integer; . i,j :integer; . lastBF,lastLR,firstBF,firstLR :char; . Lx,Ly,Lzag :extended; . .BEGIN . readln(w,d); . If (w=0)or(d=0)then . begin . writeln('0.0000'); . Halt; . End; . {initialisation} . readln(x0,y0); . readln(x1,y1); . readln(way); . If way='' then . Begin . writeln((sqrt(sqr(x0-x1)+sqr(y0-y1))):0:4); . Halt; . End; . Leng:=length(way); . firstBF:='0'; . firstLR:='0'; . {finding last and first of B and F} . {finding number of B and F} . For i:=1 to leng do . If (way[i]='B')or(way[i]='F')then . Begin . lastBF:=way[i]; . IF firstBF='0' then . firstBF:=way[i]; . inc(BF); . End; . {finding last and first of L and R} . {finding number of L and R} . For i:=1 to leng do . If (way[i]='L')or(way[i]='R')then . Begin . lastLR:=way[i]; . IF firstLR='0' then . firstLR:=way[i]; . inc(LR); . End; . {finding length of route} . IF firstBF='B' then . Ly:=d-y0 . else Ly:=y0; . IF firstLR='L' then . Lx:=x0 . else Lx:=w-x0; . IF lastBF='B' then . Ly:=Ly+d-y1 . else Ly:=Ly+y1; . IF lastLR='L' then . Lx:=Lx+x1 . else Lx:=Lx+w-x1; . Lx:=Lx+w*(LR-1); . Ly:=Ly+d*(BF-1); . Lzag:=sqrt(Lx*Lx+Ly*Ly); . Writeln(Lzag:0:4); .END. PS. Ican't see the difference between AC code from forum. Edited by author 20.08.2005 02:34 Re: I had WA on test #2. Why did it happened? Help me, please. Послано Loky 10 авг 2006 08:49 It's not so simple as you think, but simple in real. Try this test 4 6 2 1 2 5 R --- Your answer is 4.0000, but write answer is 5.6569 Re: I had WA on test #2. Why did it happened? Help me, please. Послано OZone3 3 июл 2009 05:37 Thanks, good test! No subject Thanke you, Ozone, you realy helped me! |
|
|