Codeforces Beta Round 49 (Div. 2)
D
Physical Education
Codeforces
1500
原题
← CE →
翻译中…

Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the following order: $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$, where $*a*_{*i*}$ is the height of the $*i*$-th student in the line and $*n*$ is the number of students in the line. The children find it hard to keep in mind this strange arrangement, and today they formed the line in the following order: $*b*_{1}, *b*_{2}, ..., *b*_{*n*}$, which upset Vasya immensely. Now Vasya wants to rearrange the children so that the resulting order is like this: $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$. During each move Vasya can swap two people who stand next to each other in the line. Help Vasya, find the sequence of swaps leading to the arrangement Vasya needs. It is not required to minimize the number of moves.

翻译中…

Input

翻译中…

The first line contains an integer $*n*$ ($1 ≤ *n* ≤ 300$) which is the number of students. The second line contains $*n*$ space-separated integers $*a*_{*i*}$ ($1 ≤ *a*_{*i*} ≤ 10^{9}$) which represent the height of the student occupying the $*i*$-th place must possess. The third line contains $*n*$ space-separated integers $*b*_{*i*}$ ($1 ≤ *b*_{*i*} ≤ 10^{9}$) which represent the height of the student occupying the $*i*$-th place in the initial arrangement. It is possible that some students possess similar heights. It is guaranteed that it is possible to arrange the children in the required order, i.e. $*a*$ and $*b*$ coincide as multisets.

翻译中…

Output

翻译中…

In the first line print an integer $*k*$ ($0 ≤ *k* ≤ 10^{6}$) which is the number of moves. It is not required to minimize $*k*$ but it must not exceed $10^{6}$. Then print $*k*$ lines each containing two space-separated integers. Line $*p*_{*i*}$, $*p*_{*i*} + 1$ ($1 ≤ *p*_{*i*} ≤ *n* - 1$) means that Vasya should swap students occupying places $*p*_{*i*}$ and $*p*_{*i* + 1}$.

翻译中…

样例

Input #1
4
1 2 3 2
3 2 1 2
Output #1
4
2 3
1 2
3 4
2 3
InputCopy OutputCopy
Input #2
2
1 100500
1 100500
Output #2
0
InputCopy OutputCopy
题目信息
题号
53D
时间限制
2 s
内存限制
256 MB
标签
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。