結果

問題 No.402 最も海から遠い場所
ユーザー kk
提出日時 2021-04-16 02:13:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 3,000 ms
コード長 710 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 208,536 KB
実行使用メモリ 47,500 KB
最終ジャッジ日時 2023-09-15 04:52:23
合計ジャッジ時間 3,851 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,444 KB
testcase_16 AC 5 ms
4,692 KB
testcase_17 AC 48 ms
24,496 KB
testcase_18 AC 71 ms
47,444 KB
testcase_19 AC 49 ms
47,500 KB
testcase_20 AC 70 ms
47,484 KB
testcase_21 AC 54 ms
47,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int INF = 1e6;

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

  int H, W;
  cin >> H >> W;

  vector<string> bd;
  bd.push_back(string(W + 2, '.'));
  for (int i = 0; i < H; i++) {
    string tmp;
    cin >> tmp;
    tmp = "." + tmp + ".";
    bd.push_back(tmp);
  }
  bd.push_back(string(W + 2, '.'));

  vector<vector<int> > dp(H + 2, vector<int>(W + 2));

  int ret = 0;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (bd[i][j] == '#') {
        dp[i][j] = min({dp[i-1][j], dp[i][j-1], dp[i-1][j-1]}) + 1;
        ret = max(ret, dp[i][j]);
      }
    }
  }

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