結果

問題 No.402 最も海から遠い場所
ユーザー sekiya9311sekiya9311
提出日時 2016-08-28 13:40:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 3,468 ms
コンパイル使用メモリ 77,936 KB
実行使用メモリ 98,476 KB
最終ジャッジ日時 2024-04-26 16:55:53
合計ジャッジ時間 11,168 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 125 ms
40,756 KB
testcase_07 AC 114 ms
40,160 KB
testcase_08 AC 129 ms
41,360 KB
testcase_09 AC 122 ms
40,332 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 726 ms
98,476 KB
testcase_20 WA -
testcase_21 AC 777 ms
98,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yuki402 {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int H, W;
		H = sc.nextInt();
		W = sc.nextInt();
		sc.nextLine();
		int[][] dp = new int[H][W];
		int ans = 0;
		for (int i = 0; i < H; i++) {
			String s = sc.nextLine();
			for (int j = 0; j < W; j++) {
				if (s.charAt(j) == '.') {
					dp[i][j] = 0;
				} else {
					boolean can = false;
					if (i - 1 >= 0) {
						dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]);
						can = true;
					}
					if (j - 1 >= 0) {
						dp[i][j] = Math.min(dp[i][j], dp[i][j - 1]);
						can = true;
					}
					if (i - 1 >= 0 && j - 1 >= 0) {
						dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1]);
						can = true;
					}
					if (!can)
						continue;
					dp[i][j]++;
					ans = Math.max(ans, dp[i][j]);
				}
			}
		}
		ans = (ans + 1) / 2;
		System.out.println(ans);
	}
}
0