結果

問題 No.2456 Stamp Art
ユーザー hiro1729hiro1729
提出日時 2023-09-02 06:42:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 882 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 10,824 KB
実行使用メモリ 330,912 KB
最終ジャッジ日時 2023-09-02 06:42:29
合計ジャッジ時間 9,352 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,184 KB
testcase_01 AC 16 ms
8,136 KB
testcase_02 AC 16 ms
7,804 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

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