結果
問題 | No.402 最も海から遠い場所 |
ユーザー | AreTrash |
提出日時 | 2016-05-22 13:04:37 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,050 ms / 3,000 ms |
コード長 | 1,309 bytes |
コンパイル時間 | 3,177 ms |
コンパイル使用メモリ | 77,420 KB |
実行使用メモリ | 119,428 KB |
最終ジャッジ日時 | 2024-04-24 03:06:32 |
合計ジャッジ時間 | 10,921 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
54,052 KB |
testcase_01 | AC | 128 ms
54,000 KB |
testcase_02 | AC | 143 ms
54,112 KB |
testcase_03 | AC | 129 ms
54,148 KB |
testcase_04 | AC | 127 ms
54,324 KB |
testcase_05 | AC | 127 ms
54,100 KB |
testcase_06 | AC | 125 ms
54,032 KB |
testcase_07 | AC | 115 ms
52,816 KB |
testcase_08 | AC | 125 ms
54,108 KB |
testcase_09 | AC | 116 ms
52,984 KB |
testcase_10 | AC | 124 ms
53,768 KB |
testcase_11 | AC | 128 ms
53,860 KB |
testcase_12 | AC | 115 ms
52,972 KB |
testcase_13 | AC | 169 ms
54,524 KB |
testcase_14 | AC | 161 ms
54,320 KB |
testcase_15 | AC | 277 ms
58,124 KB |
testcase_16 | AC | 365 ms
57,788 KB |
testcase_17 | AC | 733 ms
79,404 KB |
testcase_18 | AC | 1,050 ms
117,888 KB |
testcase_19 | AC | 1,032 ms
119,428 KB |
testcase_20 | AC | 1,002 ms
119,224 KB |
testcase_21 | AC | 987 ms
119,356 KB |
ソースコード
import java.util.Scanner; class Yuki2_1{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int H = sc.nextInt(); int W = sc.nextInt(); int map[][] = new int[H + 2][W + 2]; for(int i = 1; i <= H; i++){ String input = sc.next(); for(int j = 1; j <= W; j++){ if(input.charAt(j - 1) == '#') map[i][j] = 1510; } } for(int i = 1; i <= H; i++){ for(int j = 1; j <= W; j++){ map[i][j] = min4(map[i][j], map[i - 1][j] + 1, map[i][j - 1] + 1, map[i - 1][j - 1] + 1); } } for(int i = H; i >= 1; i--){ for(int j = 1; j <= W; j++){ map[i][j] = min4(map[i][j], map[i + 1][j] + 1, map[i][j - 1] + 1, map[i + 1][j - 1] + 1); } } for(int i = 1; i <= H; i++){ for(int j = W; j >= 1; j--){ map[i][j] = min4(map[i][j], map[i - 1][j] + 1, map[i][j + 1] + 1, map[i - 1][j + 1] + 1); } } for(int i = H; i >= 1; i--){ for(int j = W; j >= 1; j--){ map[i][j] = min4(map[i][j], map[i + 1][j] + 1, map[i][j + 1] + 1, map[i + 1][j + 1] + 1); } } int max = 0; for(int i = 1; i <= H; i++){ for(int j = 1; j <= W; j++){ max = Math.max(max, map[i][j]); } } System.out.println(max); } public static int min4(int a1, int a2, int a3, int a4){ return Math.min(a1, Math.min(a2, Math.min(a3, a4))); } }