Want to try solving this problem? You can submit your code online if you log in or register.
Have you ever heard of Melodramia, my friend? It is a land of magic forests and mysterious swamps, of sprinting heroines and dashing heroes. And it is home to two dragons, Rose and Scarlet, who, despite their competitive streak, are the best of friends.
Rose and Scarlet love playing snap tag, a game for two players on an grid. The game goes as follows:
Rose and Scarlet are both snap tag experts and always find a winning strategy if one exists. If it is not possible for either player to gain the upper hand, then the game goes on forever.
In this task, you are given the size of the grid and the starting locations of both dragons. You must write a program to determine how the game ends: Does Rose win? Does Scarlet win? Does the game go on forever?
The input file will contain six space separated integers on a single line, in the format: R C rROSE cROSE rSCARLET cSCARLET where:
Output should consist of a single upper-case word with no punctuation.
ROSE
.
SCARLET
.
DRAW
.
2 3 1 1 2 3
ROSE
In the first example, Rose can guarantee herself a win if she is clever and cautious.
On her first move, Rose steps to the right. Then, no matter whether Scarlet goes up or left on her turn, Rose can tag her the next turn.
5 1 2 1 4 1
SCARLET
In the second example, Scarlet can guarantee herself a win if she is clever and cautious.
If Rose moves down, then Scarlet will tag her on her very next turn. Otherwise, if Rose moves up, then Scarlet moves up and Rose will be forced to move down next to Scarlet, who will tag her the next turn.
15 15 3 5 12 13
ROSE
In the third example, Rose can guarantee herself a win if she is clever and cautious.
Privacy
statement
© Australian Mathematics Trust 2001-2023
Page generated: 24 March 2023, 9:03pm AEDT