아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Corrupted Sort

시간 제한2초메모리 제한512 MB

요약
클로이는 두 위치를 비교·교환하도록 요청할 수 있고 교환 여부만 들을 수 있지만, 2n번마다 코너가 몰래 임의의 두 카드를 바꿔 놓는다. 10000번 이하의 연산으로 카드를 정렬해야 한다.
난이도

보통10점 중 7점

유형
정렬, 시뮬레이션, 구현
정답자
아직 제출이 없습니다

문제

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 pos_ipos\_i and pos_jpos\_j (1≤pos_i<pos_j≤n1 \le pos\_i < pos\_j \le n). Connor looks at the cards on positions pos_ipos\_i and pos_jpos\_j, and if the card on position pos_ipos\_i has a bigger number than the card on position pos_jpos\_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

  1. 예제 1

    입력
    3
    
    SWAPPED
    
    STAYED
    
    WIN
    
    예상 출력
    1 2
    
    1 3
    
    2 3