Logo
(追記) (追記ここまで)

32366번 - Swipe 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB52151334.211%

문제

Swipe is a new mobile game that has recently exploded in popularity. In each level of Swipe, you are given 2 rows of integers that can be represented as arrays A and B of size N. The objective of Swipe is to beat each level by turning array A into array B.

There are two swipe operations you can perform on array A.

  • Swipe right: Select the subarray [l, r] and set Ai = Al for all l ≤ i ≤ r.
  • Swipe left: Select the subarray [l, r] and set Ai = Ar for all l ≤ i ≤ r.

For example, starting with array A = [0, 1, 2, 3, 4, 5], if we swipe right on [2, 4], we would obtain the array [0, 1, 2, 2, 2, 5]. If instead, we started with the same array A, and swiped left on [3, 5], we would obtain the array [0, 1, 2, 5, 5, 5]. 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 A into array B. If it is possible, determine a sequence of swipe operations that transforms array A into array B.

입력

The first line of input will consist of one positive integer N, representing the length of each of the two arrays of integers.

The second line of input contains N space separated integers contained in array A.

The third line of input contains N space separated integers contained in array B.

출력

The first line of output will contain YES if there is a sequence of swipes that can transform array A into array B; 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 K (K ≤ N), indicating the number of swipes.

Each of the next K lines contain three space-separated values: Dj, lj, and rj. The value Dj will be either R or L, indicating that the jth swipe is either a right or left swipe, respectively. The values lj and rj indicate the left-end and right-end of the swipe where 0 ≤ lj ≤ rj < N.

제한

서브태스크

Subtask Score Bounds on N Bounds on Ai and Bi
1 2 N = 2 1 ≤ Ai, Bi ≤ 3
2 4 1 ≤ N ≤ 8 1 ≤ Ai, Bi ≤ 8
3 4 1 ≤ N ≤ 500 1 ≤ Ai, Bi ≤ 3000
4 5 1 ≤ N ≤ 300 000 1 ≤ Ai, Bi ≤ 300 000

Note that for a subtask worth M points, you will receive ⌊M/2⌋ marks for a solution that only correctly outputs the first line of output.

예제 입력 1

3
3 1 2
3 1 1

예제 출력 1

YES
1
R 1 2

예제 입력 2

4
1 2 4 3
1 4 2 3

예제 출력 2

NO

예제 입력 3

4
2 1 4 3
2 1 4 3

예제 출력 3

YES
0

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2024 > CCC 2024 Senior Division 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /