結果
問題 | No.1344 Typical Shortest Path Sum |
ユーザー | tenten |
提出日時 | 2024-03-13 15:47:51 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 2,161 bytes |
コンパイル時間 | 2,113 ms |
コンパイル使用メモリ | 87,936 KB |
実行使用メモリ | 53,444 KB |
最終ジャッジ日時 | 2024-09-29 22:53:19 |
合計ジャッジ時間 | 10,748 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
51,428 KB |
testcase_01 | AC | 67 ms
51,456 KB |
testcase_02 | AC | 66 ms
51,476 KB |
testcase_03 | AC | 69 ms
51,428 KB |
testcase_04 | AC | 71 ms
51,188 KB |
testcase_05 | AC | 67 ms
51,444 KB |
testcase_06 | AC | 68 ms
51,520 KB |
testcase_07 | AC | 72 ms
51,404 KB |
testcase_08 | AC | 68 ms
51,404 KB |
testcase_09 | AC | 67 ms
51,128 KB |
testcase_10 | AC | 65 ms
51,612 KB |
testcase_11 | AC | 66 ms
51,468 KB |
testcase_12 | AC | 69 ms
51,456 KB |
testcase_13 | AC | 72 ms
51,384 KB |
testcase_14 | AC | 71 ms
51,340 KB |
testcase_15 | AC | 67 ms
51,556 KB |
testcase_16 | AC | 86 ms
51,556 KB |
testcase_17 | AC | 67 ms
51,180 KB |
testcase_18 | AC | 67 ms
51,416 KB |
testcase_19 | AC | 67 ms
51,428 KB |
testcase_20 | AC | 67 ms
51,416 KB |
testcase_21 | AC | 68 ms
51,196 KB |
testcase_22 | AC | 67 ms
51,076 KB |
testcase_23 | AC | 70 ms
51,308 KB |
testcase_24 | AC | 71 ms
51,080 KB |
testcase_25 | AC | 68 ms
51,100 KB |
testcase_26 | AC | 67 ms
51,448 KB |
testcase_27 | AC | 67 ms
51,388 KB |
testcase_28 | AC | 70 ms
51,264 KB |
testcase_29 | AC | 70 ms
51,436 KB |
testcase_30 | AC | 70 ms
51,064 KB |
testcase_31 | AC | 67 ms
51,432 KB |
testcase_32 | AC | 67 ms
51,432 KB |
testcase_33 | AC | 68 ms
51,068 KB |
testcase_34 | AC | 72 ms
51,500 KB |
testcase_35 | AC | 71 ms
51,424 KB |
testcase_36 | AC | 69 ms
51,368 KB |
testcase_37 | AC | 72 ms
51,476 KB |
testcase_38 | AC | 68 ms
51,200 KB |
testcase_39 | AC | 69 ms
51,400 KB |
testcase_40 | AC | 96 ms
52,116 KB |
testcase_41 | AC | 105 ms
51,952 KB |
testcase_42 | AC | 96 ms
52,020 KB |
testcase_43 | AC | 97 ms
52,036 KB |
testcase_44 | AC | 97 ms
52,044 KB |
testcase_45 | AC | 97 ms
51,924 KB |
testcase_46 | AC | 98 ms
52,016 KB |
testcase_47 | AC | 95 ms
51,796 KB |
testcase_48 | AC | 95 ms
51,768 KB |
testcase_49 | AC | 96 ms
52,032 KB |
testcase_50 | AC | 98 ms
52,020 KB |
testcase_51 | AC | 98 ms
52,024 KB |
testcase_52 | AC | 98 ms
51,812 KB |
testcase_53 | AC | 97 ms
52,132 KB |
testcase_54 | AC | 98 ms
51,752 KB |
testcase_55 | AC | 102 ms
52,020 KB |
testcase_56 | AC | 102 ms
51,864 KB |
testcase_57 | AC | 94 ms
52,072 KB |
testcase_58 | AC | 101 ms
52,000 KB |
testcase_59 | AC | 97 ms
51,928 KB |
testcase_60 | AC | 79 ms
51,452 KB |
testcase_61 | AC | 71 ms
51,432 KB |
testcase_62 | AC | 127 ms
53,444 KB |
testcase_63 | AC | 84 ms
51,556 KB |
testcase_64 | AC | 93 ms
51,792 KB |
testcase_65 | AC | 131 ms
53,400 KB |
testcase_66 | AC | 128 ms
53,236 KB |
testcase_67 | AC | 128 ms
53,176 KB |
testcase_68 | AC | 83 ms
51,336 KB |
testcase_69 | AC | 82 ms
51,280 KB |
testcase_70 | AC | 74 ms
51,208 KB |
testcase_71 | AC | 69 ms
51,460 KB |
testcase_72 | AC | 72 ms
51,084 KB |
testcase_73 | AC | 77 ms
51,140 KB |
testcase_74 | AC | 77 ms
51,388 KB |
testcase_75 | AC | 71 ms
51,140 KB |
testcase_76 | AC | 69 ms
51,268 KB |
testcase_77 | AC | 67 ms
51,064 KB |
testcase_78 | AC | 70 ms
51,524 KB |
testcase_79 | AC | 76 ms
51,432 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static long[] facts; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); long[][] distances = new long[n][n]; for (int i = 0; i < n; i++) { Arrays.fill(distances[i], Long.MAX_VALUE / 2); distances[i][i] = 0; } for (int i = 0; i < m; i++) { int s = sc.nextInt() - 1; int t = sc.nextInt() - 1; distances[s][t] = Math.min(distances[s][t], sc.nextLong()); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { distances[j][k] = Math.min(distances[j][k], distances[j][i] + distances[i][k]); } } } String result = IntStream.range(0, n).mapToObj(i -> { long current = IntStream.range(0, n) .mapToLong(j -> distances[i][j] > Long.MAX_VALUE / 3 ? 0 : distances[i][j]) .sum(); return String.valueOf(current); }).collect(Collectors.joining("\n")); System.out.println(result); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }