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

18732번 - A Permutation Problem 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB72342849.123%

문제

Zenyk has a permutation of n integers from 1 to n, inclusive. His task is to sort the permutation, and he has to swap each pair of integers exactly once.

Can you help him to do that?

입력

The first line contains a single integer n (2 ≤ n ≤ 1000). The second line contains the permutation P of integers between 1 and n.

출력

Print “no” if it’s impossible to sort the permutation. Otherwise, print n(n−1)/2 lines that describe the pairs of values (not indices) to swap on the corresponding turn.

제한

예제 입력 1

4
3 2 4 1

예제 출력 1

1 2
4 1
1 3
2 3
2 4
3 4

예제 입력 2

3
1 3 2

예제 출력 2

1 3
3 2
1 2

예제 입력 3

2
1 2

예제 출력 3

no

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 6: Lviv NU Contest C번

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

출처

대학교 대회

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

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