ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1299. Psylonians

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
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
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
if x>100 then x:=100;
if p> 20 then p:= 20;
case ch of
'G':guard;
'A':attack;
'P':patrol;
'D':defense;
end;
end.
Posted by Heng 15 Aug 2012 08:14
WA14～