codingame/FACILE/Skynet : le saut/script.php
2015-03-02 19:42:39 +01:00

46 lines
1,007 B
PHP

<?php
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
fscanf(STDIN, "%d",
$R // the length of the road before the gap.
);
fscanf(STDIN, "%d",
$G // the length of the gap.
);
fscanf(STDIN, "%d",
$L // the length of the landing platform.
);
// game loop
while (TRUE)
{
fscanf(STDIN, "%d",
$S // the motorbike's speed.
);
fscanf(STDIN, "%d",
$X // the position on the road of the motorbike.
);
// Write an action using echo(). DON'T FORGET THE TRAILING \n
// To debug (equivalent to var_dump): error_log(var_export($var, true));
if ($X + 1 === $R) {
echo("JUMP\n");
}
elseif($G < $S - 1) {
echo("SLOW\n");
}
elseif ($X >= $R + $G) {
echo("SLOW\n");
}
elseif ($G == $S - 1) {
echo("WAIT\n");
}
else {
echo("SPEED\n"); // A single line containing one of 4 keywords: SPEED, SLOW, JUMP, WAIT.
}
}
?>