using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int matsuCount = int.Parse(Reader.ReadLine()); int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); matsuCount = inpt.Length; inpt.ToList().ForEach(a=>this.Matsu.Add(this.Matsu.Count, a)); StringBuilder ans = new StringBuilder(); int conv = 0; for(int i=0; ia.Key >= i).OrderBy(a=>a.Value).First().Key; if(i != min) { conv++; ans.AppendLine(i + " " + min); int tmp = this.Matsu[i]; this.Matsu[i] = this.Matsu[min]; this.Matsu[min] = tmp; } } Console.WriteLine(conv); Console.Write(ans.ToString()); string dummy = Reader.ReadLine(); } private Dictionary Matsu = new Dictionary(); private Dictionary Goal = new Dictionary(); public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 6 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 -1 "; 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(); } }