結果

問題 No.92 逃走経路
ユーザー bluemeganebluemegane
提出日時 2021-05-18 11:13:11
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,497 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 113,432 KB
実行使用メモリ 32,140 KB
最終ジャッジ日時 2024-04-17 00:46:23
合計ジャッジ時間 2,779 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 34 ms
19,584 KB
testcase_02 AC 35 ms
19,456 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 41 ms
20,224 KB
testcase_06 AC 42 ms
20,440 KB
testcase_07 AC 43 ms
20,092 KB
testcase_08 AC 39 ms
20,224 KB
testcase_09 AC 90 ms
23,936 KB
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Linq;
using System.Collections.Generic;
using System;

public struct P
{
    public int from { get; set; }
    public int fee { get; set; }
}

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var k = int.Parse(line[2]);
        var d = new Dictionary<P, int>();
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            var c = int.Parse(line[2]);
            var p0 = new P { from = a, fee = c };
            var p1 = new P { from = b, fee = c };
            d[p0] = b;
            d[p1] = a;
        }
        getAns(n, d);
    }
    static void getAns ( int n, Dictionary<P,int> d)
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var k = Array.ConvertAll(line, int.Parse);
        var ans = Enumerable.Range(1, n).ToList();
        var ans2 = new List<int>();
        foreach(var x in k)
        {
            foreach(var y in ans)
            {
                var p = new P { from = y, fee = x };
                if (d.ContainsKey(p)) ans2.Add(d[p]);
            }
            ans.Clear();
            foreach (var y in ans2) ans.Add(y);
            ans2.Clear();
        }
        Console.WriteLine(ans.Count());
        Console.WriteLine(string.Join(" ",ans));
    }
}
0