Submission #1779175
Source Code Expand
import java.util.*; import java.io.*; public class Main { private static IO io = new IO(); public static void main(String[] args) { int n = io.nextInt(); int m = io.nextInt(); int d[][] = new int[n][n]; int INF = 1145141919; for (int i = 0; i < n; i++) { Arrays.fill(d[i], INF); d[i][i] = 0; } for (int i = 0; i < m; i++) { int a = io.nextInt()-1; int b = io.nextInt()-1; int c = io.nextInt(); d[a][b] = d[b][a] = Math.min(d[a][b], c); } for (int k = 0; k < n; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]); } } } int ans = INF; for (int i = 0; i < n; i++) { int tmp = 0; for (int j = 0; j < n; j++) { tmp = Math.max(tmp, d[i][j]); } ans = Math.min(ans, tmp); } System.out.println(ans); } static class IO extends PrintWriter { private final InputStream in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; IO() { this(System.in); } IO(InputStream source) { super(System.out); this.in = source; } boolean hasNextByte() { if (ptr < buflen) return true; else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) return false; } return true; } int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } boolean isPrintableChar(int c) {return 33<=c &&c <=126;} void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;} boolean hasNext() { skipUnprintable(); return hasNextByte(); } long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) throw new NumberFormatException(); while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n; else throw new NumberFormatException(); b = readByte(); } } int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public void close() { super.close(); try { in.close(); } catch (IOException ignored) { } } } }
Submission Info
Submission Time | |
---|---|
Task | D - バスと避けられない運命 |
User | creep04 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 3400 Byte |
Status | WA |
Exec Time | 155 ms |
Memory | 23252 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 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 | WA | 67 ms | 19408 KB |
sample_02.txt | WA | 67 ms | 19028 KB |
sample_03.txt | AC | 68 ms | 23252 KB |
test_01.txt | AC | 68 ms | 19028 KB |
test_02.txt | WA | 121 ms | 20180 KB |
test_03.txt | AC | 155 ms | 22104 KB |
test_04.txt | WA | 104 ms | 21972 KB |
test_05.txt | AC | 120 ms | 22688 KB |
test_06.txt | AC | 102 ms | 19888 KB |
test_07.txt | AC | 142 ms | 19284 KB |
test_08.txt | AC | 72 ms | 21460 KB |
test_09.txt | AC | 122 ms | 20480 KB |
test_10.txt | AC | 99 ms | 20656 KB |
test_11.txt | AC | 104 ms | 22832 KB |
test_12.txt | WA | 126 ms | 19348 KB |
test_13.txt | AC | 108 ms | 18976 KB |
test_14.txt | AC | 109 ms | 19488 KB |
test_15.txt | AC | 132 ms | 20736 KB |
test_16.txt | AC | 106 ms | 22432 KB |
test_17.txt | AC | 119 ms | 20512 KB |
test_18.txt | WA | 118 ms | 20624 KB |
test_19.txt | AC | 113 ms | 22960 KB |
test_20.txt | WA | 118 ms | 21020 KB |
test_21.txt | AC | 67 ms | 18516 KB |
test_22.txt | WA | 116 ms | 22940 KB |
test_23.txt | AC | 73 ms | 21460 KB |
test_24.txt | WA | 121 ms | 21588 KB |
test_25.txt | WA | 124 ms | 20180 KB |
test_26.txt | WA | 97 ms | 19156 KB |
test_27.txt | WA | 99 ms | 20180 KB |
test_28.txt | WA | 121 ms | 22100 KB |
test_29.txt | WA | 121 ms | 22100 KB |
test_30.txt | WA | 92 ms | 22100 KB |
test_31.txt | WA | 85 ms | 18644 KB |
test_32.txt | WA | 120 ms | 22100 KB |
test_33.txt | WA | 121 ms | 20052 KB |
test_34.txt | WA | 88 ms | 20052 KB |
test_35.txt | WA | 97 ms | 21588 KB |
test_36.txt | WA | 120 ms | 20180 KB |