結果

問題 No.92 逃走経路
ユーザー mbanmban
提出日時 2017-01-12 07:10:33
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 3,077 bytes
コンパイル時間 3,241 ms
コンパイル使用メモリ 108,504 KB
実行使用メモリ 52,196 KB
最終ジャッジ日時 2023-08-23 08:39:36
合計ジャッジ時間 19,739 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 64 ms
22,544 KB
testcase_02 AC 64 ms
24,452 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 140 ms
24,744 KB
testcase_06 AC 88 ms
22,784 KB
testcase_07 AC 88 ms
24,688 KB
testcase_08 AC 86 ms
32,024 KB
testcase_09 AC 115 ms
44,736 KB
testcase_10 WA -
testcase_11 AC 2,034 ms
45,792 KB
testcase_12 AC 4,050 ms
51,008 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static private Magatro M = new Magatro();
    static private void Main(string[]args)
    {
        M.Scan();
        M.Solve();
    }
}
public class Scanner
{
    private string[] S;
    private int Index;
    private char Separator;
    public Scanner(char separator = ' ')
    {
        Index = 0;
        Separator = separator;
    }
    private string[] Line()
    {
        return Console.ReadLine().Split(Separator);
    }
    public string Next()
    {
        string result;
        if (S == null || Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}
public class Magatro
{
    private int N, M, K;
    private int[] d;
    private List<int>[] Load;
    private List<int>[] Fee;
    private HashSet<int> Anser = new HashSet<int>();
    public void Scan()
    {
        Scanner sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        K = sc.NextInt();
        Load = new List<int>[N];
        Fee = new List<int>[N];
        for(int i = 0; i < N; i++)
        {
            Load[i] = new List<int>();
            Fee[i] = new List<int>();
        }
        for (int i = 0; i < M; i++)
        {
            int a = sc.NextInt();
            int b = sc.NextInt();
            int c = sc.NextInt();
            Load[a - 1].Add(b-1);
            Load[b - 1].Add(a-1);
            Fee[a - 1].Add(c);
            Fee[b - 1].Add(c);
        }
        d = new int[K];
        for(int i = 0; i < K; i++)
        {
            d[i] = sc.NextInt();
        }
    }
    public void Solve()
    {
        for(int i = 0; i < N; i++)
        {
            HashSet<int>[] to = new HashSet<int>[K];
            for(int j = 0; j < K; j++)
            {
                to[j] = new HashSet<int>();
                if (j == 0)
                {
                    for (int k = 0; k < Load[i].Count; k++)
                    {
                        if (Fee[i][k] == d[j]) to[j].Add(Load[i][k]);
                    }
                }
                else
                {
                    foreach(int k in to[j - 1])
                    {
                        for(int l = 0; l < Load[k].Count; l++)
                        {
                            if (Fee[k][l] == d[j]) to[j].Add(Load[k][l]);
                        }
                    }
                }
            }
            foreach(int ans in to[K - 1])
            {
                Anser.Add(ans+1);
            }

        }
        Console.WriteLine(Anser.Count);
        Console.WriteLine(string.Join(" ", Anser));
    }
}
0