結果

問題 No.1344 Typical Shortest Path Sum
ユーザー keymoon
提出日時 2021-01-17 00:34:16
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 4,426 ms
コンパイル使用メモリ 110,960 KB
実行使用メモリ 27,508 KB
最終ジャッジ日時 2024-11-28 15:52:23
合計ジャッジ時間 7,560 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 77
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        long[][] mat = Enumerable.Repeat(0, n).Select(_ => Enumerable.Repeat(long.MaxValue / 2, n).ToArray()).ToArray();
        for (int i = 0; i < n; i++) mat[i][i] = 0;
        for (int i = 0; i < m; i++)
        {
            var st = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            mat[st[0] - 1][st[1] - 1] = Min(mat[st[0] - 1][st[1] - 1], st[2]);
        }
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    mat[j][k] = Min(mat[j][k], mat[j][i] + mat[i][k]);
        for (int i = 0; i < n; i++) Console.WriteLine(mat[i].Sum(x => long.MaxValue / 4 < x ? 0 : x));
    }
}
0