結果
問題 |
No.326 あみだますたー
|
ユーザー |
![]() |
提出日時 | 2015-12-19 14:37:12 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,752 bytes |
コンパイル時間 | 1,305 ms |
コンパイル使用メモリ | 115,600 KB |
実行使用メモリ | 29,544 KB |
最終ジャッジ日時 | 2024-09-16 16:04:55 |
合計ジャッジ時間 | 6,253 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | AC * 3 WA * 23 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; namespace No326 { class MainClass { private class Edge { readonly int _first; public int First { get { return _first; } } readonly int _second; public int Second { get { return _second; } } public Edge(int first, int second) { _first = first; _second = second; } } private static void SwapPositions(List<int> positions, List<Edge> edges) { foreach (var edge in edges) { var temp = positions [edge.First - 1]; positions [edge.First - 1] = positions [edge.Second - 1]; positions [edge.Second - 1] = temp; } } public static void Main (string[] args) { var n = Convert.ToInt32 (Console.ReadLine ()); var k = Convert.ToInt32 (Console.ReadLine ()); List<Edge> edges = new List<Edge> (); for (int i = 0; i < k; i++) { var line = Console.ReadLine ().Split (' ').Select (_ => Convert.ToInt32 (_)).ToArray (); edges.Add(new Edge(line[0],line[1])); } var positions = Enumerable.Range (1, n).ToList (); SwapPositions (positions, edges); var targetLine = Console.ReadLine ().Split (' ').Select (_ => Convert.ToInt32 (_)).ToArray (); var addingList = new List<Edge> (); for (int i = 0; i < n; i++) { var left = targetLine [i]; var index = positions.IndexOf (left); List<Edge> list = new List<Edge> (); for(int j = index; j > left;j--) { list.Add(new Edge(j, j-1)); } SwapPositions(positions, list); addingList.AddRange(list); } Console.WriteLine(addingList.Count.ToString()); foreach(var edge in addingList) { Console.WriteLine (edge.First.ToString() + " " + edge.Second.ToString()); } } } }