結果
問題 |
No.402 最も海から遠い場所
|
ユーザー |
![]() |
提出日時 | 2016-08-28 13:36:44 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 792 bytes |
コンパイル時間 | 3,337 ms |
コンパイル使用メモリ | 78,148 KB |
実行使用メモリ | 113,340 KB |
最終ジャッジ日時 | 2024-11-14 06:17:54 |
合計ジャッジ時間 | 11,894 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 2 WA * 17 |
ソースコード
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 { dp[i][j] = (int) 1e9; if (i - 1 >= 0) dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]); if (j - 1 >= 0) dp[i][j] = Math.min(dp[i][j], dp[i][j - 1]); if (i - 1 >= 0 && j - 1 >= 0) dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1]); dp[i][j]++; ans = Math.max(ans, dp[i][j]); } } } ans = (ans + 1) / 2; System.out.println(ans); } }