結果

問題 No.402 最も海から遠い場所
ユーザー jp_ste
提出日時 2016-08-12 21:02:57
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,019 ms / 3,000 ms
コード長 1,157 bytes
コンパイル時間 5,825 ms
コンパイル使用メモリ 77,340 KB
実行使用メモリ 130,836 KB
最終ジャッジ日時 2024-11-07 12:16:06
合計ジャッジ時間 11,917 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main2 {
    static Scanner scan = new Scanner(System.in);
    
    static int[] dx = {-1, -1, 0};
    static int[] dy = {0, -1, -1};
    
    public static void main(String[] args) {
        
        int H = scan.nextInt();
        int W = scan.nextInt();
        
        char[][] map = new char[H][W];
        int [][] ansMap = new int[H][W];
        int ans = 0;
        
        for(int i=0; i<H; i++) {
            map[i] = scan.next().toCharArray();
        }
        
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                if(map[i][j] == '.') continue;
         
                int v = Integer.MAX_VALUE;
                if(i==0 || j==0) {
                    v = 1;
                } else {
                    for(int k=0; k<dx.length; k++) {
                        int nx = j + dx[k];
                        int ny = i + dy[k];
                        v = Math.min(v, ansMap[ny][nx]+1);
                    }
                }
                ansMap[i][j] = v;
                ans = Math.max(ans, v);
            }
        }
        System.out.println((ans+1)/2);
    }
}
0