using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int tatebouCount = int.Parse(Reader.ReadLine()); int yokobobuCount = int.Parse(Reader.ReadLine()); Dictionary swapDic = new Dictionary(); for(int i=1; i<= tatebouCount; i++) { swapDic.Add(i, i); } for(int i=0; iint.Parse(a)).ToArray(); int tmp = swapDic[inpt[0]]; swapDic[inpt[0]] = swapDic[inpt[1]]; swapDic[inpt[1]] = tmp; } List ans = new List(); int[] goal = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); for(int i=0; ia.Value == goal[i]).Select(a=>a.Key).First(); if(targetIdx - 1 == i) { continue; } for (int j = targetIdx - 1; j > i; j--) { ans.Add(new int[]{j, j+1}); int tmp = swapDic[j+1]; swapDic[j+1] = swapDic[j]; swapDic[j] = tmp; } } Console.WriteLine(ans.Count); ans.ForEach(a=>Console.WriteLine(a[0] + " " + a[1])); } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 5 6 1 2 3 4 2 3 3 4 1 2 4 5 5 1 4 3 2 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }