Corrupted Sort | 프로그래밍의 벗 PivotOJ
PivotOJ

Corrupted Sort

시간 제한: 2000ms메모리 제한: 512MB출처: ICPC 2020-2021 Northwestern Russia Regional ContestBOJ 20234

문제

Chloe wants to test her sorting skills. She has nn cards with distinct integers from 11 to nn written on them. She asks her little brother Connor to first blindfold her and then arrange all cards in a row in some order. Positions of cards are numbered from 11 to nn from left to right.

Chloe doesn't know the order of the cards, but she wants to sort them, so that the leftmost card has number 11 and the rightmost card has number nn on it. Formally, for each ii she wants the card on position ii to have number ii on it. To achieve the goal, Chloe can ask Connor to do one or more operations.

Each operation can be denoted by two integers posipos_i and posjpos_j (1posi<posjn1 \le pos_i < pos_j \le n). Connor looks at the cards on positions posipos_i and posjpos_j, and if the card on position posipos_i has a bigger number than the card on position posjpos_j, he swaps them. Otherwise, he does nothing. Connor also tells Chloe if he swapped the cards or not.

To make the game more interesting, after every 2n2n operations Connor chooses two distinct cards uniformly at random and swaps them without telling anything to Chloe.

If after some of Chloe's operations all cards become sorted, Chloe wins. Help Chloe to sort all cards using at most 10 00010\ 000 operations.

힌트

Initial card ordering in the example was 33 11 22 (that is, the card on position 11 had number 33 on it, the card on position 22 had number 11, and the card on position 33 had number 22).

예제

예제 1

입력
3

SWAPPED

STAYED

WIN
출력
1 2

1 3

2 3
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.