Increasing or Decreasing
시간 제한1초메모리 제한256 MB
순열 A를 순열 B로 바꾸는 문제로, 구간을 오름차순이나 내림차순으로 정렬하는 연산을 n번 이하로 사용해야 합니다.
문제
You are given two permutations and of size . You want to transform to in no more than operations of the following kind:
- Choose a subsegment of 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 is ok.
입력
The first line contains one integer () --- the sizes of both permutations.
The second line contains the permutation .
The third line contains the permutation .
출력
On the first line print one integer () --- the number of operations.
On the next lines print the descriptions of operation. One description has a form (, is 'I' or 'D') and means sort the subsegment 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.