結果
| 問題 | 
                            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 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 | 
コンパイルメッセージ
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();
    }
}
            
            
            
        
            
14番