4691: 小强盗女孩动物园

内存限制:256 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:30 通过:14

题目描述

小强盗女孩喜欢在动物园里吓唬动物取乐。她决定把动物按高度不减的顺序排成一排。然而,这些动物非常害怕,以至于他们无法呆在正确的地方。

女孩起初很生气,但后来她决定自己安排动物。她反复给出一个区间,区间的左右边界分别为l和r,且区间内的元素个数为偶数,即r-l+1为偶数。之后,lr之间位置的动物被重新排列如下:l位置的动物与l+1位置的动物互换位置,l+2位置的动物和l+3位置的动物互换位置,……,最后,r-1位置的宠物与r位置的动物交换位置。
帮助女孩按照不降度顺序排列动物。每次最多进行20000次交换就可以完成排序,否则女孩会变得无聊,并再次开始惊吓动物。



题目描述

Little Robber Girl likes to scare animals in her zoo for fun. She decided to arrange the animals in a row in the order of non-decreasing height. However, the animals were so scared that they couldn't stay in the right places.
The robber girl was angry at first, but then she decided to arrange the animals herself. She repeatedly names numbers l and r such that rl+1 is even. After that animals that occupy positions between l and r inclusively are rearranged as follows: the animal at position l swaps places with the animal at position l+1 , the animal l+2 swaps with the animal l+3 , ..., finally, the animal at position r1 swaps with the animal r .
Help the robber girl to arrange the animals in the order of non-decreasing height. You should name at most 2000020000 segments, since otherwise the robber girl will become bored and will start scaring the animals again.

输入格式

The first line contains a single integer n ( 1<=n<=100 ) — number of animals in the robber girl's zoo.
The second line contains n space-separated integers a1,a2,...,an ( 1<=ai<=109 ), where ai is the height of the animal occupying the i -th place.

输出格式


Output
Print the sequence of operations that will rearrange the animals by non-decreasing height.
The output should contain several lines, i-th of the lines should contain two space-separated integers li and ri (1≤li<rin)− descriptions of segments the robber girl should name. The segments should be described in the order the operations are performed.
The number of operations should not exceed 20000.
If the animals are arranged correctly from the start, you are allowed to output nothing.


输入格式

第一行包含单个整数n(1≤n≤100)-抢劫女孩动物园里的动物数量。

第二行包含n个空格分隔的整数a1,a2,…,an(1≤ai≤109),其中ai是占据第i位的动物的高度。

输出格式

打印将按非降低高度重新排列动物的操作顺序。

输出应包含几行,第i行应包含两个空格分隔的整数li和ri(1≤li<ri≤n)-抢劫女孩应该说出的片段描述这些段。

操作次数不应超过20000次。

如果动物从一开始就被正确地排列,你就可以不输出任何东西。

 

Examples
Input
4
2 1 4 3
Output
1 4
Input
7
36 28 57 39 66 69 68
Output
1 4
6 7
Input
5
1 2 1 2 1
Output
2 5
3 4
1 4
1 4


Note
Note that you don't have to minimize the number of operations. Any solution that performs at most 20000 operations is allowed.


请注意,您不必尽量减少操作数。允许最多执行 20000 个操作的任何解决方案。

输入样例 复制

4
2 1 4 3

输出样例 复制

1 2
3 4

数据范围与提示

这道题可能会有许多种可行答案,为了判断答案正误,这里统一采用最原始的暴力枚举法,与用例2和3 给出的答案不同,请不用带入题目给的几个用例计算。
请同学们按照:
输入:
4
2 1 4 3
输出:
1 2
3 4
相近的思路进行答案提交,谢谢。