#K36777. Island Treasures
Island Treasures
Island Treasures
You are given an island exploration problem where Bob starts at an initial coordinate \((x_0, y_0)\) and must perform a specified sequence of movements repeatedly. Each test case provides:
- Initial conditions: the number of treasures \(n\), the number of repetitions \(M\) of the movement sequence, and Bob’s starting coordinates \((x_0, y_0)\).
- A list of \(n\) treasure coordinates \((a_i, b_i)\).
- A movement sequence that may include the following operations:
- Translation (T dx dy): \((x, y) \to (x + dx, y + dy)\).
- Vertical Scaling (VS sy): \((x, y) \to (x, y \times sy)\).
- Horizontal Scaling (HS sx): \((x, y) \to (x \times sx, y)\).
- Flip over x-axis (FX): \((x, y) \to (x, -y)\).
- Flip over y-axis (FY): \((x, y) \to (-x, y)\).
Bob applies the entire movement sequence exactly \(M\) times. After these moves, for each treasure provided, if Bob's final coordinates exactly match a treasure's coordinates, output TREASURE FOUND
; otherwise, output TREASURE LOST
for that treasure. Each treasure’s result is printed on a new line.
inputFormat
The input is read from standard input (stdin) and has the following format:
P n M x0 y0 a1 b1 a2 b2 ... an bn K [operation1] [operation2] ... [operationK] ... (repeated for each of the P test cases)
Where:
P
is the number of test cases.- For each test case, the first line contains four integers: \(n\) (the number of treasures), \(M\) (the number of times the movement sequence is executed), \(x_0\), and \(y_0\) (the starting coordinates).
- The next line contains \(2n\) integers representing the coordinates of the treasures.
- The following line contains an integer
K
that denotes the number of moves in the sequence. - Each of the next
K
lines describes a move in one of the following formats:T dx dy
for a translation.VS sy
for vertical scaling.HS sx
for horizontal scaling.FX
for flipping over the x-axis.FY
for flipping over the y-axis.
outputFormat
For each treasure in each test case, output a line with either TREASURE FOUND
if Bob's final position matches the treasure's coordinates or TREASURE LOST
otherwise. The output should be written to standard output (stdout).
3
2 1 0 0
2 3 -4 5
3
T 1 -1
VS 2
HS -1
1 1 0 0
1 -2
3
T 1 -1
VS 2
HS 1
2 2 0 0
2 3 -4 5
3
T 1 2
VS 1
HS 1
TREASURE LOST
TREASURE LOST
TREASURE FOUND
TREASURE LOST
TREASURE LOST
</p>