結果

問題 No.92 逃走経路
ユーザー bluemeganebluemegane
提出日時 2021-05-18 11:14:12
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,517 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 106,752 KB
実行使用メモリ 34,424 KB
最終ジャッジ日時 2024-04-17 00:48:27
合計ジャッジ時間 2,681 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 33 ms
19,200 KB
testcase_02 AC 36 ms
19,200 KB
testcase_03 AC 35 ms
19,200 KB
testcase_04 AC 35 ms
19,328 KB
testcase_05 AC 42 ms
20,096 KB
testcase_06 AC 43 ms
20,448 KB
testcase_07 AC 42 ms
20,296 KB
testcase_08 AC 41 ms
19,968 KB
testcase_09 AC 89 ms
23,808 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();
        }
        ans.Sort();
        Console.WriteLine(ans.Count());
        Console.WriteLine(string.Join(" ",ans));
    }
}
0