結果

問題 No.402 最も海から遠い場所
ユーザー GiriGiri
提出日時 2023-06-25 17:21:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 137 ms / 3,000 ms
コード長 594 bytes
コンパイル時間 1,377 ms
コンパイル使用メモリ 164,380 KB
実行使用メモリ 47,488 KB
最終ジャッジ日時 2023-09-15 09:55:47
合計ジャッジ時間 3,685 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 4 ms
4,608 KB
testcase_14 AC 4 ms
5,048 KB
testcase_15 AC 12 ms
7,704 KB
testcase_16 AC 14 ms
8,868 KB
testcase_17 AC 136 ms
31,516 KB
testcase_18 AC 137 ms
47,488 KB
testcase_19 AC 102 ms
5,572 KB
testcase_20 AC 131 ms
47,436 KB
testcase_21 AC 115 ms
47,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 3005;

int H, W;
int f[MAXN][MAXN];
bool c[MAXN][MAXN];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> H >> W;
    char t;
    for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) {
        cin >> t;
        if (t=='#') c[i][j] = 1;
    }
    int ans = 0;
    for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) {
        if (c[i][j]) f[i][j] = min(f[i - 1][j - 1], min(f[i][j - 1], f[i - 1][j])) + 1;
        ans = max(ans, f[i][j]);
    }
    cout << (ans + 1) / 2;

    return 0;
}
0