結果

問題 No.2456 Stamp Art
ユーザー hiro1729hiro1729
提出日時 2023-09-02 06:42:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,402 ms / 5,000 ms
コード長 882 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 327,972 KB
最終ジャッジ日時 2023-09-02 11:22:38
合計ジャッジ時間 29,880 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,216 KB
testcase_01 AC 74 ms
71,016 KB
testcase_02 AC 73 ms
71,292 KB
testcase_03 AC 1,312 ms
318,756 KB
testcase_04 AC 79 ms
71,064 KB
testcase_05 AC 89 ms
76,260 KB
testcase_06 AC 1,421 ms
318,888 KB
testcase_07 AC 1,315 ms
302,312 KB
testcase_08 AC 1,152 ms
321,228 KB
testcase_09 AC 1,449 ms
303,244 KB
testcase_10 AC 2,402 ms
270,956 KB
testcase_11 AC 1,510 ms
327,972 KB
testcase_12 AC 1,614 ms
301,652 KB
testcase_13 AC 2,151 ms
314,496 KB
testcase_14 AC 2,228 ms
293,220 KB
testcase_15 AC 1,174 ms
318,592 KB
testcase_16 AC 891 ms
212,800 KB
testcase_17 AC 94 ms
76,192 KB
testcase_18 AC 76 ms
75,588 KB
testcase_19 AC 889 ms
310,704 KB
testcase_20 AC 1,994 ms
270,636 KB
testcase_21 AC 1,705 ms
281,096 KB
testcase_22 AC 1,784 ms
302,356 KB
testcase_23 AC 171 ms
81,928 KB
testcase_24 AC 290 ms
94,072 KB
testcase_25 AC 75 ms
71,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
s = [input() for _ in range(h)]
v = [[0] * (w + 1) for _ in range(h + 1)]
for i in range(h):
	for j in range(w):
		if s[i][j] == '#': v[i + 1][j + 1] += 1
		v[i + 1][j + 1] += v[i + 1][j] + v[i][j + 1] - v[i][j]
def f(x):
	c = [[0] * (w + 2) for _ in range(h + 2)]
	for i in range(h - x + 1):
		for j in range(w - x + 1):
			if v[i + x][j + x] - v[i + x][j] - v[i][j + x] + v[i][j] == x * x:
				k, l = i + 1, j + 1
				c[k][l] += 1
				c[k + x][l] -= 1
				c[k][l + x] -= 1
				c[k + x][l + x] += 1
	for i in range(h + 1):
		for j in range(w):
			c[i][j + 1] += c[i][j]
	for i in range(h):
		for j in range(w + 1):
			c[i + 1][j] += c[i][j]
	for i in range(h):
		for j in range(w):
			if s[i][j] == '#' and c[i + 1][j + 1] == 0:
				return 0
	return 1
l = 1
r = min(h, w) + 1
while l + 1 < r:
	m = (l + r) // 2
	if f(m): l = m
	else: r = m
print(l)
0