結果

問題 No.402 最も海から遠い場所
ユーザー y_mazuny_mazun
提出日時 2017-01-20 15:49:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 97 ms / 3,000 ms
コード長 875 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 62,484 KB
実行使用メモリ 47,848 KB
最終ジャッジ日時 2023-08-24 18:19:07
合計ジャッジ時間 2,326 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,504 KB
testcase_01 AC 2 ms
5,604 KB
testcase_02 AC 2 ms
5,684 KB
testcase_03 AC 2 ms
5,492 KB
testcase_04 AC 2 ms
5,500 KB
testcase_05 AC 2 ms
5,532 KB
testcase_06 AC 2 ms
5,552 KB
testcase_07 AC 2 ms
5,612 KB
testcase_08 AC 2 ms
5,632 KB
testcase_09 AC 2 ms
5,540 KB
testcase_10 AC 2 ms
5,796 KB
testcase_11 AC 2 ms
5,636 KB
testcase_12 AC 2 ms
5,616 KB
testcase_13 AC 3 ms
8,056 KB
testcase_14 AC 3 ms
8,256 KB
testcase_15 AC 8 ms
13,148 KB
testcase_16 AC 9 ms
13,452 KB
testcase_17 AC 73 ms
34,344 KB
testcase_18 AC 97 ms
47,608 KB
testcase_19 AC 61 ms
47,848 KB
testcase_20 AC 91 ms
47,660 KB
testcase_21 AC 74 ms
47,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

#include <cstring>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int d[3010][3010];
char g[3010][3010];

inline int get(int x, int y, int w, int h) {
  return ISIN(x, y, w, h) ? d[y][x] : 0;
}

int main(){
  const int h = getInt();
  const int w = getInt();
  REP(i,h) scanf("%s", g[i]);

  int ans = 0;
  REP(i,h) REP(j,w) {
    if (g[i][j] == '.') d[i][j] = 0;
    else d[i][j] = min(get(j - 1, i, w, h),
		       min(get(j, i - 1, w, h),
			   get(j - 1, i - 1, w, h))) + 1;
    ans = max(ans, d[i][j]);
  }

  // REP(i,h) { REP(j,w) printf("%02d ", d[i][j]); puts(""); }

  printf("%d\n", (ans + 1) / 2);
  return 0;
}
0