結果
問題 | No.101 ぐるぐる!あみだくじ! |
ユーザー | 14番 |
提出日時 | 2016-04-12 01:04:20 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,634 bytes |
コンパイル時間 | 1,136 ms |
コンパイル使用メモリ | 115,440 KB |
実行使用メモリ | 54,516 KB |
最終ジャッジ日時 | 2024-10-04 06:47:56 |
合計ジャッジ時間 | 3,926 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
24,688 KB |
testcase_01 | AC | 224 ms
52,900 KB |
testcase_02 | AC | 223 ms
54,516 KB |
testcase_03 | AC | 31 ms
23,352 KB |
testcase_04 | AC | 29 ms
27,448 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
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 | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 31 ms
27,604 KB |
testcase_35 | AC | 31 ms
25,448 KB |
testcase_36 | AC | 28 ms
25,316 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
コンパイルメッセージ
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.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int lineCount = int.Parse(Reader.ReadLine()); int inputCount = int.Parse(Reader.ReadLine()); Dictionary<int, int> dic = new Dictionary<int, int>(); List<int> numList = new List<int>(); int ans = lineCount; for (int i = 1; i <= lineCount; i++) { numList.Add(i-1); } List<AmidaLine> amidaList = new List<AmidaLine>(); for (int i = 0; i < inputCount; i++) { int[] inpt = Reader.GetInt(); AmidaLine al = new AmidaLine(inpt[0]-1, inpt[1]-1, i); amidaList.Add(al); } for (int i = 0; i < lineCount; i++) { int pos = -1; int idx = i; for (int j = 0; j < inputCount; j++) { List<AmidaLine> select = new List<AmidaLine>(amidaList.FindAll(a => (a.Line1 == idx || a.Line2 == idx) && a.Pos > pos).OrderBy(b => b.Pos)); if (select.Count == 0) { break; } pos = select[0].Pos; idx = select[0].Goto(idx); } dic.Add(i, idx); } for (int i = 0; i < lineCount; i++) { int[] conv = new int[lineCount]; for (int j = 0; j < numList.Count; j++) { conv[dic[j]] = numList[j]; } numList.Clear(); numList.AddRange(conv); bool isMatch = true; for (int j = 0; j < numList.Count; j++) { if (j != numList[j]) { isMatch = false; break; } } if (isMatch) { ans = i + 1; break; } } Console.WriteLine(ans); } public class AmidaLine { public int Line1; public int Line2; public int Pos; public int Goto(int from) { if (from == Line1) { return Line2; } return Line1; } public AmidaLine(int l1, int l2, int p) { this.Line2 = l2; this.Line1 = l1; this.Pos = p; } } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 4 6 1 2 2 3 3 4 3 4 2 3 1 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(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }