Submission #1691393
Source Code Expand
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] a = new int[m]; int[] b = new int[m]; int[] t = new int[m]; for(int i = 0 ; i < m ; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); t[i] = sc.nextInt(); } int[][] graph = new int[n][n]; for(int i = 0 ; i < n ; i++) { for(int j = 0 ; j < n ; j++) { if(i == j) graph[i][j] = 0; else graph[i][j] = Integer.MAX_VALUE / 2; } } for(int i = 0 ; i < m ; i++) { int u = a[i], v = b[i], c = t[i]; u--;v--; graph[u][v] = graph[v][u] = c; } for(int k = 0 ; k < n ; k++) { for(int i = 0 ; i < n ; i++) { for(int j = 0 ; j < n ; j++) { graph[i][j] = Math.min(graph[i][j], graph[i][k] + graph[k][j]); } } } int min = 1001001001; for(int i = 0 ; i < n ; i++) { int max = -1001001001; for(int j = 0 ; j < n ; j++) { max = Math.max(max, graph[i][j]); } min = Math.min(min, max); } System.out.println(min); } }
Submission Info
Submission Time | |
---|---|
Task | D - バスと避けられない運命 |
User | kouta1612 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 1125 Byte |
Status | AC |
Exec Time | 549 ms |
Memory | 60040 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 101 ms | 21204 KB |
sample_02.txt | AC | 100 ms | 21716 KB |
sample_03.txt | AC | 102 ms | 18900 KB |
test_01.txt | AC | 100 ms | 20560 KB |
test_02.txt | AC | 201 ms | 24308 KB |
test_03.txt | AC | 549 ms | 60040 KB |
test_04.txt | AC | 248 ms | 28400 KB |
test_05.txt | AC | 411 ms | 43024 KB |
test_06.txt | AC | 217 ms | 31604 KB |
test_07.txt | AC | 476 ms | 47916 KB |
test_08.txt | AC | 155 ms | 23060 KB |
test_09.txt | AC | 399 ms | 44212 KB |
test_10.txt | AC | 209 ms | 29600 KB |
test_11.txt | AC | 220 ms | 32492 KB |
test_12.txt | AC | 268 ms | 35944 KB |
test_13.txt | AC | 209 ms | 31528 KB |
test_14.txt | AC | 253 ms | 34624 KB |
test_15.txt | AC | 466 ms | 45900 KB |
test_16.txt | AC | 242 ms | 37216 KB |
test_17.txt | AC | 417 ms | 45636 KB |
test_18.txt | AC | 257 ms | 34644 KB |
test_19.txt | AC | 282 ms | 40312 KB |
test_20.txt | AC | 233 ms | 35276 KB |
test_21.txt | AC | 106 ms | 19028 KB |
test_22.txt | AC | 248 ms | 34656 KB |
test_23.txt | AC | 136 ms | 21844 KB |
test_24.txt | AC | 205 ms | 25736 KB |
test_25.txt | AC | 196 ms | 23564 KB |
test_26.txt | AC | 166 ms | 19496 KB |
test_27.txt | AC | 167 ms | 23680 KB |
test_28.txt | AC | 201 ms | 23668 KB |
test_29.txt | AC | 196 ms | 24564 KB |
test_30.txt | AC | 136 ms | 19284 KB |
test_31.txt | AC | 126 ms | 20820 KB |
test_32.txt | AC | 201 ms | 26052 KB |
test_33.txt | AC | 201 ms | 25488 KB |
test_34.txt | AC | 133 ms | 20052 KB |
test_35.txt | AC | 171 ms | 23184 KB |
test_36.txt | AC | 201 ms | 22708 KB |