結果
問題 | No.92 逃走経路 |
ユーザー | 14番 |
提出日時 | 2016-04-10 20:47:17 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 835 ms / 5,000 ms |
コード長 | 3,337 bytes |
コンパイル時間 | 1,105 ms |
コンパイル使用メモリ | 114,080 KB |
実行使用メモリ | 53,984 KB |
最終ジャッジ日時 | 2024-10-04 05:54:59 |
合計ジャッジ時間 | 5,696 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 279 ms
28,732 KB |
testcase_01 | AC | 28 ms
24,216 KB |
testcase_02 | AC | 30 ms
26,260 KB |
testcase_03 | AC | 29 ms
26,144 KB |
testcase_04 | AC | 29 ms
24,208 KB |
testcase_05 | AC | 175 ms
53,984 KB |
testcase_06 | AC | 50 ms
19,968 KB |
testcase_07 | AC | 51 ms
20,096 KB |
testcase_08 | AC | 36 ms
19,584 KB |
testcase_09 | AC | 95 ms
22,784 KB |
testcase_10 | AC | 495 ms
22,784 KB |
testcase_11 | AC | 522 ms
22,912 KB |
testcase_12 | AC | 835 ms
34,176 KB |
testcase_13 | AC | 53 ms
22,784 KB |
testcase_14 | AC | 75 ms
22,912 KB |
testcase_15 | AC | 139 ms
22,912 KB |
testcase_16 | AC | 142 ms
22,656 KB |
testcase_17 | AC | 238 ms
22,912 KB |
testcase_18 | AC | 160 ms
22,528 KB |
testcase_19 | AC | 112 ms
23,040 KB |
コンパイルメッセージ
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[] inpt = Reader.GetInt(); int matiCount = inpt[0]; int roadCount = inpt[1]; int queryCount = inpt[2]; List<Road> roadList = new List<Road>(); for (int i = 0; i < roadCount; i++) { inpt = Reader.GetInt(); Road rd = new Road(inpt[0], inpt[1], inpt[2]); roadList.Add(rd); } int[] history = Reader.GetInt(); List<int> target = new List<int>(); roadList.FindAll((a) => { return (a.Cost == history[0]); }).ForEach((a) => { if (!target.Contains(a.Mati1)) { target.Add(a.Mati1); } if (!target.Contains(a.Mati2)) { target.Add(a.Mati2); } }); for (int i = 1; i < history.Length; i++) { List<int> nextTarget = new List<int>(); ; target.ForEach((a) => { roadList.FindAll((b) => { return (b.Mati1 == a || b.Mati2 == a) && b.Cost == history[i]; }).ForEach((c) => { if (c.Mati1 != a && (!nextTarget.Contains(c.Mati1))) { nextTarget.Add(c.Mati1); } else if(c.Mati2 != a && (!nextTarget.Contains(c.Mati2))) { nextTarget.Add(c.Mati2); } }); }); target = nextTarget; if (nextTarget.Count == 0) { break; } } target.Sort(); Console.WriteLine(target.Count); Console.WriteLine(string.Join<int>(" ", target)); } public class Road { public int Mati1; public int Mati2; public int Cost; public Road(int m1, int m2, int c) { this.Mati1 = m1; this.Mati2 = m2; this.Cost = c; } } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 3 2 2 1 2 10 1 2 20 10 20 "; 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(); } }