結果

問題 No.326 あみだますたー
ユーザー nanophoto12nanophoto12
提出日時 2015-12-19 14:55:26
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,943 bytes
コンパイル時間 2,423 ms
コンパイル使用メモリ 108,844 KB
実行使用メモリ 23,952 KB
最終ジャッジ日時 2023-10-14 22:26:47
合計ジャッジ時間 8,457 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,724 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 67 ms
21,720 KB
testcase_06 AC 69 ms
21,664 KB
testcase_07 AC 67 ms
21,716 KB
testcase_08 AC 79 ms
23,776 KB
testcase_09 AC 81 ms
23,760 KB
testcase_10 AC 82 ms
21,656 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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;
			}
			DumpCurrent (positions);
		}

		private static void DumpCurrent(List<int> positions)
		{
			//Console.WriteLine ("current = " + String.Join (",", positions));
		}

		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 > i;j--)
				{
					list.Add(new Edge(j , j + 1));
				}
				SwapPositions(positions, list);
				addingList.AddRange(list);
			}
			DumpCurrent (positions);
			Console.WriteLine(addingList.Count.ToString());
			foreach(var edge in addingList)
			{
				Console.WriteLine (edge.First.ToString() + " " + edge.Second.ToString());
			}
		}
	}
}
0