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

21091번 - Increasing or Decreasing 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB109565350.476%

문제

You are given two permutations $A$ and $B$ of size $n$. You want to transform $A$ to $B$ in no more than $n$ operations of the following kind:

  • Choose a subsegment $[l;r]$ of $A$ and sort it in either increasing or decreasing order.

Note that you don't have to minimize the number of operations, any sequence of operations of length not more than $n$ is ok.

입력

The first line contains one integer $n$ (1ドル \le n \le 500$) --- the sizes of both permutations.

The second line contains the permutation $A_{1}, A_{2}, \ldots, A_{n}$.

The third line contains the permutation $B_{1}, B_{2}, \ldots, B_{n}$.

출력

On the first line print one integer $m$ (0ドル \le m \le n$) --- the number of operations.

On the next $m$ lines print the descriptions of operation. One description has a form $l_{i}$ $r_{i}$ $t_{i}$ (1ドル \le l_{i} \le r_{i} \le n,ドル $t_{i}$ is 'I' or 'D') and means sort the subsegment $[l_{i};r_{i}]$ in (I)ncreasing or (D)ecreasing order.

If there are different solutions any one will be accepted. It is guaranteed that there is at least one solution.

제한

예제 입력 1

5
2 4 5 1 3
5 4 3 2 1

예제 출력 1

1
1 5 D

예제 입력 2

5
5 4 3 2 1
3 2 5 1 4

예제 출력 2

4
2 5 I
1 4 I
1 3 D
3 4 D

예제 입력 3

5
3 1 4 5 2
3 1 4 5 2

예제 출력 3

0

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 5: Almost Retired Dandelion Contest, ICPC Camp Contest 2 J번

Contest > Open Cup > 2020/2021 Season > Stage 11: Grand Prix of Nizhny Novgorod J번

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

출처

대학교 대회

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

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