結果

問題 No.402 最も海から遠い場所
ユーザー hiyokko2hiyokko2
提出日時 2016-07-31 16:59:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 1,129 ms
コンパイル使用メモリ 157,828 KB
実行使用メモリ 47,468 KB
最終ジャッジ日時 2024-04-24 13:18:48
合計ジャッジ時間 3,384 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 4 ms
8,280 KB
testcase_14 AC 3 ms
8,452 KB
testcase_15 AC 9 ms
10,728 KB
testcase_16 AC 10 ms
14,476 KB
testcase_17 AC 126 ms
31,536 KB
testcase_18 AC 204 ms
47,360 KB
testcase_19 AC 184 ms
47,468 KB
testcase_20 WA -
testcase_21 AC 182 ms
47,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

int H, W;
char grid[3000][3000];
int dp[3000][3000];

int min3(int a, int b, int c)
{
	return min(a, min(b, c));
}

int getLargestSquare(int H, int W)
{
	rep(i,H)
	{
		rep(j,W)
		{
			if (grid[i][j] == '.')
			{
				dp[i][j] = 0;
			}
			else if (grid[i][j] == '#')
			{
				dp[i][j] = 1;
			}
		}
	}

	int maxWidth = 0;
	for (int i=1; i<H; i++)
	{
		for (int j=1; j<W; j++)
		{
			if (grid[i][j] == '.')
			{
				dp[i][j] = 0;
			}
			else
			{
				dp[i][j] = min3(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1;
				maxWidth = max(maxWidth, dp[i][j]);
			}
		}
	}

	return maxWidth;
}

signed main()
{
	//入力
	cin >> H >> W;
	rep(i,H)
	{
		cin >> grid[i];
	}

	printf("%d\n", (getLargestSquare(H, W) + 1) / 2);
}
0