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 1299. Psylonians

WHY? Wrong Answer???
Posted by Heng 15 Aug 2012 07:55
program URAL1299(input,output);
  var n,np,m,mp,p,x,yg:longint;
    ch:char;
  procedure gfire;
    begin
      if (abs(yg)>=10)or(m=0)
         then writeln('FRONT ',x)
         else writeln( 'FIRE ',p);
    end;
  procedure bfire;
    begin
      if (abs(yg)>=5)or(m=0)
         then writeln('BACKWARD ',x)
         else writeln('FIRE ',p);
    end;
  procedure attack;
    begin
      readln(n,np);
      if n*np>=3*m*mp
         then gfire
         else bfire;
    end;
  procedure guard;
    begin
      if m=0 then begin
         writeln('STOP');exit;
      end;
      if abs(yg)<5
         then writeln('FIRE ',p)
         else begin
         if yg>=+5 then writeln( 'LEFT ',x);
         if yg<=-5 then writeln('RIGHT ',x);
         end;
    end;
  procedure defense;
    begin
      if m*20>=p
      then bfire
      else guard;
    end;
  procedure patrol;
    begin
      readln(yg);//yg:=yg+180;
      if m>0 then defense else begin
        if abs(yg)<=20 then writeln('FRONT ',x) else
        if abs(yg)>=160then writeln('BACKWARD ',x)else
           begin
             if yg<-90 then yg:=+180-abs(yg);
             if yg>+90 then yg:=-180+abs(yg);
             if yg>  0 then writeln('LEFT ',x)
                       else writeln('RIGHT ',x);
           end;
      end;
    end;
  begin
    readln(x,p);
    if x>100 then x:=100;
    if p> 20 then p:= 20;
    readln(ch);readln(m,mp,yg);
    case ch of
      'G':guard;
      'A':attack;
      'P':patrol;
      'D':defense;
    end;
  end.
Re: WHY? Wrong Answer???
Posted by Heng 15 Aug 2012 08:14
WA14~
Re: WHY? Wrong Answer???
Posted by [SPb NRU ITMO] Niyaz Nigmatullin 22 Feb 2013 22:23
>if x>100 then x:=100;
>if p> 20 then p:= 20;

You have to use initial values, while finding solution.

>     if n*np>=3*m*mp
This has to be n*np>3*m*mp

My solution failed on 14th test, because mine was written like:
if n*np*3>m*mp