#P10297. [CCC 2024 S3] Swipe
[CCC 2024 S3] Swipe
Problem Description
Swipe is a new mobile game that has recently become very popular. In each level of Swipe, you are given two sequences and of length . The goal of each level is to turn array into array .
There are now two types of swipe operations that can be applied to .
- Swipe right: choose an interval , and for every , set .
- Swipe left: choose an interval , and for every , set .
For example, initially . If we perform a swipe right on interval , the sequence becomes . If we perform a swipe left on interval , the sequence becomes . Note that the sequence is indexed starting from .
Unfortunately, the game has some issues and may contain levels that cannot be cleared. Determine whether it is possible to transform array into array . If it is possible, output any sequence of swipe operations that transforms into .
Input Format
The first line contains a positive integer , the length of the two sequences.
The second line contains integers from , separated by spaces.
The third line contains integers from , separated by spaces.
Output Format
If there exists a sequence of operations that can turn into , output YES on the first line; otherwise output NO.
If you output YES on the first line, then the next line contains a non-negative integer (), the number of swipes.
In the next lines, each line contains three space-separated values: , , and . is R or L, indicating whether the -th operation is a swipe right or a swipe left.
and are the left and right endpoints of the swipe, and must satisfy .
3
3 1 2
3 1 1
YES
1
R 1 2
4
1 2 4 3
1 4 2 3
NO
4
2 1 4 3
2 1 4 3
YES
0
Hint
This problem uses bundled testdata.
For all testdata, it is guaranteed that , and .
The following table shows the distribution of the points:
| Points | Range of | Range of and |
|---|---|---|
Note that for a subtask worth points, if you only answer the first line correctly, you can get points.
Translated by ChatGPT 5