結果

問題 No.402 最も海から遠い場所
ユーザー jp_stejp_ste
提出日時 2016-08-12 20:42:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 962 ms / 3,000 ms
コード長 1,522 bytes
コンパイル時間 3,759 ms
コンパイル使用メモリ 78,048 KB
実行使用メモリ 118,584 KB
最終ジャッジ日時 2024-04-25 02:40:01
合計ジャッジ時間 12,363 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
40,128 KB
testcase_01 AC 129 ms
41,076 KB
testcase_02 AC 131 ms
41,324 KB
testcase_03 AC 129 ms
41,204 KB
testcase_04 AC 113 ms
39,936 KB
testcase_05 AC 129 ms
41,164 KB
testcase_06 AC 140 ms
41,564 KB
testcase_07 AC 132 ms
41,160 KB
testcase_08 AC 134 ms
40,880 KB
testcase_09 AC 131 ms
40,972 KB
testcase_10 AC 135 ms
41,184 KB
testcase_11 AC 139 ms
41,120 KB
testcase_12 AC 141 ms
41,556 KB
testcase_13 AC 188 ms
41,756 KB
testcase_14 AC 160 ms
41,728 KB
testcase_15 AC 267 ms
45,292 KB
testcase_16 AC 378 ms
48,512 KB
testcase_17 AC 728 ms
82,572 KB
testcase_18 AC 938 ms
118,512 KB
testcase_19 AC 828 ms
118,408 KB
testcase_20 AC 962 ms
118,400 KB
testcase_21 AC 893 ms
118,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Scanner;

public class Main2 {
    static Scanner scan = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    static int H, W;
    static char[][] map;
    static int [][] ansMap;
    
    static int[] dx = {-1, -1, 0};
    static int[] dy = {0, -1, -1};
    
    public static void main(String[] args) {
        
        String line = scan.nextLine();
        String values[] = line.split(" ");
        H = Integer.parseInt(values[0]);
        W = Integer.parseInt(values[1]);;
        
        map = new char[H][W];
        ansMap = new int[H][W];
        int ans = 0;
        
        for(int i=0; i<H; i++) {
            line = scan.nextLine();
            for(int j=0; j<W; j++) {
                map[i][j] = line.charAt(j);
                if((i==0 || j==0) && map[i][j] == '#') { 
                    ansMap[i][j] = 1;
                    ans = 1;
                }
            }
        }
        
        for(int i=1; i<H; i++) {
            for(int j=1; j<W; j++) {
                if(map[i][j] == '.') continue;
                    
                int v = Integer.MAX_VALUE;
                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