結果

問題 No.402 最も海から遠い場所
ユーザー jp_stejp_ste
提出日時 2016-08-12 21:02:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 899 ms / 3,000 ms
コード長 1,157 bytes
コンパイル時間 4,410 ms
コンパイル使用メモリ 77,484 KB
実行使用メモリ 130,572 KB
最終ジャッジ日時 2024-04-25 02:40:42
合計ジャッジ時間 11,809 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
40,184 KB
testcase_01 AC 101 ms
40,204 KB
testcase_02 AC 121 ms
41,196 KB
testcase_03 AC 117 ms
41,180 KB
testcase_04 AC 108 ms
40,800 KB
testcase_05 AC 100 ms
40,032 KB
testcase_06 AC 105 ms
41,116 KB
testcase_07 AC 108 ms
40,956 KB
testcase_08 AC 107 ms
40,872 KB
testcase_09 AC 112 ms
41,324 KB
testcase_10 AC 113 ms
40,560 KB
testcase_11 AC 116 ms
40,052 KB
testcase_12 AC 116 ms
40,884 KB
testcase_13 AC 165 ms
41,872 KB
testcase_14 AC 149 ms
41,268 KB
testcase_15 AC 219 ms
44,336 KB
testcase_16 AC 282 ms
48,952 KB
testcase_17 AC 556 ms
82,524 KB
testcase_18 AC 875 ms
130,544 KB
testcase_19 AC 769 ms
130,328 KB
testcase_20 AC 899 ms
130,312 KB
testcase_21 AC 843 ms
130,572 KB
権限があれば一括ダウンロードができます

ソースコード

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