結果

問題 No.402 最も海から遠い場所
ユーザー k
提出日時 2021-04-16 02:13:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 89 ms / 3,000 ms
コード長 710 bytes
コンパイル時間 2,603 ms
コンパイル使用メモリ 202,692 KB
最終ジャッジ日時 2025-01-20 18:04:10
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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