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 ZiV 29 Jan 2006 15:13
My program passed all tests from forum, but It gets WA28 Here is my code:
Var
ygol,arm,otkl,energy,us,ensrus,enemys,ensrzapas : int64;
s : string;
Function Min(x,y : int64):int64;
Begin
if x > y then
Min := y
Else
Min := x;
End;

Procedure Oxrana;
Begin
if enemys = 0 then
Writeln('STOP')
Else
if Abs(ygol) < 5 then
Writeln('FIRE ',Min(20,arm))
Else
if ygol > 0 then
Writeln('LEFT ',Min(100,energy))
Else
Writeln('RIGHT ',Min(100,energy));
End;

Procedure Atack;
Begin
if us*ensrus > enemys*ensrzapas*3 then
if Abs(ygol) < 10 then
Writeln('FIRE ',Min(20,arm))
Else
Writeln('FRONT ',Min(100,energy))
Else
if Abs(ygol) < 5 then
Writeln('FIRE ',Min(20,arm))
Else
Writeln('BACKWARD ',Min(100,energy))
End;

Procedure Defence;
Begin
if enemys*20 >= Arm then
if Abs(ygol) < 5 then
Writeln('FIRE ',Min(20,arm))
Else
Writeln('BACKWARD ',Min(100,energy))
Else
Oxrana;
End;

Procedure Patrul;
Var
t : longint;
Begin
t := otkl;
if otkl < 0 then
Otkl := Otkl+360;
if enemys > 0 then
Defence
Else
if (Otkl>=160) and (otkl <= 200) then
Writeln('BACKWARD ',Min(100,energy))
Else
if ((otkl >= 0) and (otkl <= 20) or (otkl >= 340) and (otkl <= 360)) then
Writeln('FRONT ',Min(100,energy))
Else
if t > 0 then
Writeln('LEFT ',Min(100,energy))
Else
Writeln('RIGHT ',Min(100,energy));
End;

BEGIN
if Pos('A',s) <> 0 then
Begin
Atack;
End;
if Pos('D',s) <> 0 then
Defence;
if Pos('G',s) <> 0 then
Oxrana;
if Pos('P',s) <> 0 then
Begin
Patrul;
End;
END.