LCC '25 Contest 1 S1 - Chaotic Curses
View as PDFTwo witches, A and B, are fighting over a magical potion that can repair their wands, which were damaged from last Halloween. They decide to settle it with a game. They will curse each other's broomsticks using a sequence of commands: F (move forward), L (turn 90 degrees to the left), and R (turn 90 degrees to the right). Note that the L and R commands only change the direction of the broomstick. Because their wands are broken, they cannot control the order of commands and each curse ends up being a random string consisting of  of these 3 characters. The winner is decided by the witch who is farthest (Euclidean distance) from the starting point when the curse is complete.
Input Specification
The first line of input contains .
The next two lines contain the curses for witch A and witch B, respectively. Each curse is a string of N characters.
Output Specification
Output A if witch A wins, and B if witch B wins. If it is a tie, output TIE.
Constraints
Subtask 1 [20%]
Subtask 2 [80%]
Sample Input 1
15
FLFFRFLFFRFRFLF
FFFFFFRFFFFFFFFOutput for Sample Input 1
BExplanation of Output for Sample Input 1
Without loss of generality, assume that both witches start facing North. Witch A ends up 4 units North and 3 units West, so she is 5 units from the starting point. Witch B ends up 6 units North and 8 units East, so she is 10 units from the starting point.
Sample Input 2
6
FFLLFR
FLFRRFOutput for Sample Input 2
TIEExplanation of Output for Sample Input 2
Both witches end up 1 unit away from the starting point.
Comments