CF489A.SwapSort

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In this problem your goal is to sort an array consisting of nn integers in at most nn swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.

Note that in this problem you do not have to minimize the number of swaps — your task is to find any sequence that is no longer than nn .

输入格式

In this problem your goal is to sort an array consisting of nn integers in at most nn swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.

Note that in this problem you do not have to minimize the number of swaps — your task is to find any sequence that is no longer than nn .

输出格式

In this problem your goal is to sort an array consisting of nn integers in at most nn swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.

Note that in this problem you do not have to minimize the number of swaps — your task is to find any sequence that is no longer than nn .

输入输出样例

  • 输入#1

    5
    5 2 5 1 4
    

    输出#1

    2
    0 3
    4 2
    
  • 输入#2

    6
    10 20 20 40 60 60
    

    输出#2

    0
    
  • 输入#3

    2
    101 100
    

    输出#3

    1
    0 1
    
首页