Canadian Computing Competition: 2024 Stage 1, Senior #3
Swipe is a new mobile game that has recently exploded in popularity. In each level of Swipe, you are given rows of integers that can be represented as arrays and of size . The objective of Swipe is to beat each level by turning array into array .
There are two swipe operations you can perform on array .
For example, starting with array , if we swipe right on , we would obtain the array . If instead, we started with the same array , and swiped left on , we would obtain the array . Note that these arrays are 0-indexed.
Unfortunately, the game is bugged and contains levels that are impossible to beat. Determine if it is possible to transform array into array . If it is possible, determine a sequence of swipe operations that transforms array into array .
The first line of input will consist of one positive integer , representing the length of each of the two arrays of integers.
The second line of input contains space separated integers contained in array .
The third line of input contains space separated integers contained in array .
The following table shows how the available 15 marks are distributed:
| Marks | Bounds on | Bounds on and |
|---|---|---|
| 2 | ||
| 4 | ||
| 4 | ||
| 5 |
The first line of output will contain YES if there is a sequence of swipes that can transform array into array ; otherwise, the first line of output will contain NO.
If the first line of output is YES, the next line contains a non-negative integer (), indicating the number of swipes.
Each of the next lines contain three space-separated values: , , and . The value will be either R or L, indicating that the -th swipe is either a right or left swipe, respectively. The values and indicate the left-end and right-end of the swipe where .
Many different sequences of swipes may beat the same level. Output any sequence that satisfies the requirements above; your output does not have to match the sample output, and it is checked by replaying your swipes on array .
Swiping right on sets , which turns into .
The only in array sits at index and the only sits at index , but array needs the at index and the at index . A swipe only ever copies a value outward from one end of the range it is applied to, so two values can never cross over each other, and this level cannot be beaten.
Array is already equal to array , so no swipes are needed at all.
No comments yet. Be the first to comment!