結果

問題 No.402 最も海から遠い場所
ユーザー face4face4
提出日時 2018-11-02 14:41:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 529 ms / 3,000 ms
コード長 722 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 65,364 KB
実行使用メモリ 47,552 KB
最終ジャッジ日時 2024-04-30 16:42:25
合計ジャッジ時間 5,122 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 3 ms
6,948 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 6 ms
8,032 KB
testcase_14 AC 4 ms
9,944 KB
testcase_15 AC 18 ms
11,860 KB
testcase_16 AC 25 ms
13,988 KB
testcase_17 AC 273 ms
32,140 KB
testcase_18 AC 529 ms
47,440 KB
testcase_19 AC 490 ms
12,484 KB
testcase_20 AC 520 ms
47,476 KB
testcase_21 AC 502 ms
47,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

char mat[3000][3000];
int dp[3000][3000] = {};

int main(){
    int h, w;
    scanf("%d %d\n", &h, &w);

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            scanf("%c ", &mat[i][j]);
        }
    }

    for(int i = 0; i < h; i++)  if(mat[i][0] == '#')    dp[i][0] = 1;
    for(int j = 0; j < w; j++)  if(mat[0][j] == '#')    dp[0][j] = 1;

    int ans = 1;
    for(int i = 1; i < h; i++){
        for(int j = 1; j < w; j++){
            if(mat[i][j] == '.')    continue;
            dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j], dp[i][j-1])) + 1;
            ans = max(ans, dp[i][j]);
        }
    }

    cout << (ans+1)/2 << endl;
    
    return 0;
}
0