結果

問題 No.1344 Typical Shortest Path Sum
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2021-02-04 05:33:54
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 2,785 bytes
コンパイル時間 4,516 ms
コンパイル使用メモリ 104,924 KB
実行使用メモリ 22,920 KB
最終ジャッジ日時 2023-09-13 01:16:35
合計ジャッジ時間 12,636 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,712 KB
testcase_01 AC 59 ms
20,640 KB
testcase_02 AC 58 ms
20,652 KB
testcase_03 AC 60 ms
20,816 KB
testcase_04 AC 61 ms
22,812 KB
testcase_05 AC 60 ms
22,784 KB
testcase_06 AC 60 ms
22,752 KB
testcase_07 AC 59 ms
20,812 KB
testcase_08 AC 58 ms
22,696 KB
testcase_09 AC 59 ms
20,900 KB
testcase_10 AC 59 ms
20,768 KB
testcase_11 AC 58 ms
20,736 KB
testcase_12 AC 59 ms
22,748 KB
testcase_13 AC 58 ms
22,688 KB
testcase_14 AC 60 ms
22,676 KB
testcase_15 AC 59 ms
20,736 KB
testcase_16 AC 60 ms
20,668 KB
testcase_17 AC 60 ms
20,768 KB
testcase_18 AC 60 ms
20,720 KB
testcase_19 AC 60 ms
18,696 KB
testcase_20 AC 60 ms
22,804 KB
testcase_21 AC 60 ms
20,648 KB
testcase_22 AC 60 ms
20,804 KB
testcase_23 AC 61 ms
22,800 KB
testcase_24 AC 61 ms
18,684 KB
testcase_25 AC 60 ms
22,744 KB
testcase_26 AC 60 ms
20,764 KB
testcase_27 AC 60 ms
22,660 KB
testcase_28 AC 60 ms
18,748 KB
testcase_29 AC 60 ms
20,736 KB
testcase_30 AC 60 ms
20,700 KB
testcase_31 AC 60 ms
22,804 KB
testcase_32 AC 60 ms
20,704 KB
testcase_33 AC 60 ms
22,700 KB
testcase_34 AC 59 ms
20,632 KB
testcase_35 AC 59 ms
20,768 KB
testcase_36 AC 58 ms
20,764 KB
testcase_37 AC 59 ms
20,692 KB
testcase_38 AC 60 ms
20,760 KB
testcase_39 AC 59 ms
22,804 KB
testcase_40 AC 64 ms
22,744 KB
testcase_41 AC 64 ms
20,772 KB
testcase_42 AC 64 ms
22,780 KB
testcase_43 AC 64 ms
20,812 KB
testcase_44 AC 63 ms
20,780 KB
testcase_45 AC 62 ms
18,688 KB
testcase_46 AC 63 ms
20,756 KB
testcase_47 AC 62 ms
18,628 KB
testcase_48 AC 64 ms
20,780 KB
testcase_49 AC 63 ms
20,772 KB
testcase_50 AC 64 ms
20,752 KB
testcase_51 AC 64 ms
22,816 KB
testcase_52 AC 64 ms
20,744 KB
testcase_53 AC 64 ms
20,756 KB
testcase_54 AC 63 ms
20,868 KB
testcase_55 AC 63 ms
22,824 KB
testcase_56 AC 66 ms
20,668 KB
testcase_57 AC 64 ms
22,744 KB
testcase_58 AC 64 ms
20,688 KB
testcase_59 AC 65 ms
18,688 KB
testcase_60 AC 59 ms
18,624 KB
testcase_61 AC 59 ms
18,660 KB
testcase_62 AC 62 ms
22,704 KB
testcase_63 AC 60 ms
20,788 KB
testcase_64 AC 61 ms
22,920 KB
testcase_65 AC 62 ms
20,768 KB
testcase_66 AC 62 ms
20,692 KB
testcase_67 AC 62 ms
22,864 KB
testcase_68 AC 61 ms
22,820 KB
testcase_69 AC 60 ms
20,756 KB
testcase_70 AC 59 ms
20,652 KB
testcase_71 AC 63 ms
20,772 KB
testcase_72 AC 58 ms
18,760 KB
testcase_73 AC 58 ms
20,612 KB
testcase_74 AC 59 ms
20,752 KB
testcase_75 AC 59 ms
22,808 KB
testcase_76 AC 61 ms
22,824 KB
testcase_77 AC 59 ms
20,672 KB
testcase_78 AC 58 ms
20,680 KB
testcase_79 AC 59 ms
20,832 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using System.Threading;
using System.Runtime.CompilerServices;
static class Program{
	const int mod=(int)1e9+7;
	const long inf=long.MaxValue>>1;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int n=s[0],m=s[1];//n-1;
		var wf=new long[n+1][];
		for(int i=1;i<=n;i++){
			wf[i]=new long[n+1];
			for(int j=1;j<=n;j++){
				if(i!=j){wf[i][j]=inf;}
			}
		}
		for(int i=0;i<m;i++){
			var e=sc.La;
			wf[e[0]][e[1]]=Min(wf[e[0]][e[1]],e[2]);
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){if(wf[j][i]!=inf&&wf[i][k]!=inf){wf[j][k]=Min(wf[j][k],wf[j][i]+wf[i][k]);}}
			}
		}
		StringBuilder sb=new StringBuilder();
		for(int i=1;i<=n;i++){
			long ans=0;
			for(int j=1;j<=n;j++){
				if(wf[i][j]<inf){ans+=wf[i][j];}
			}
			sb.Append(ans+"\n");
		}
		Console.Write(sb);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}
0