結果
問題 | No.402 最も海から遠い場所 |
ユーザー | kano_town |
提出日時 | 2016-07-22 23:14:56 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,323 bytes |
コンパイル時間 | 3,510 ms |
コンパイル使用メモリ | 77,864 KB |
実行使用メモリ | 83,240 KB |
最終ジャッジ日時 | 2024-04-24 06:01:59 |
合計ジャッジ時間 | 12,600 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 135 ms
46,940 KB |
testcase_01 | AC | 128 ms
54,132 KB |
testcase_02 | AC | 145 ms
41,632 KB |
testcase_03 | WA | - |
testcase_04 | AC | 134 ms
41,472 KB |
testcase_05 | AC | 134 ms
41,332 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 133 ms
41,532 KB |
testcase_09 | AC | 127 ms
41,304 KB |
testcase_10 | AC | 134 ms
41,256 KB |
testcase_11 | AC | 144 ms
41,428 KB |
testcase_12 | AC | 138 ms
41,560 KB |
testcase_13 | AC | 213 ms
41,768 KB |
testcase_14 | AC | 214 ms
42,256 KB |
testcase_15 | AC | 605 ms
44,708 KB |
testcase_16 | AC | 976 ms
44,792 KB |
testcase_17 | TLE | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
import java.util.Scanner; public class Yukicoder402 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(), w = sc.nextInt(); String[] s = new String[h]; int[] map = new int[h * w]; int[] dx = {-1, 0, 1, -1, 1, -1, 0, 1}; int[] dy = {-1, -1, -1, 0, 0, 1, 1, 1}; for (int i = 0; i < h; i++) { s[i] = sc.next(); for (int x = 0; x < w; x++) { if (s[i].charAt(x) == '.') { map[i * w + x] = 0; } else { map[i * w + x] = 1; } } } int min, max = -1; for (int k = 1; k < 1500; k++) { for (int y = k; y < h - k; y++) { for (int x = k; x < w - k; x++) { if (map[y * w + x] != 0) { min = map[(y + dy[0]) * w + (x + dx[0])]; for (int p = 1; p < 8; p++) { min = Math.min(min, map[(y + dy[p]) * w + (x + dx[p])]); } map[y * w + x] = min + 1; max = Math.max(max, map[y * w + x]); } } } } System.out.println(max); } }