結果
問題 | No.2456 Stamp Art |
ユーザー | LyricalMaestro |
提出日時 | 2024-11-11 01:25:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,907 ms / 5,000 ms |
コード長 | 1,929 bytes |
コンパイル時間 | 599 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 280,160 KB |
最終ジャッジ日時 | 2024-11-11 01:25:48 |
合計ジャッジ時間 | 39,201 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
52,404 KB |
testcase_01 | AC | 36 ms
52,256 KB |
testcase_02 | AC | 35 ms
52,864 KB |
testcase_03 | AC | 1,998 ms
269,400 KB |
testcase_04 | AC | 35 ms
52,352 KB |
testcase_05 | AC | 53 ms
65,412 KB |
testcase_06 | AC | 2,139 ms
269,604 KB |
testcase_07 | AC | 1,988 ms
269,144 KB |
testcase_08 | AC | 1,721 ms
269,100 KB |
testcase_09 | AC | 2,137 ms
269,952 KB |
testcase_10 | AC | 2,890 ms
269,948 KB |
testcase_11 | AC | 1,978 ms
269,776 KB |
testcase_12 | AC | 2,561 ms
269,556 KB |
testcase_13 | AC | 2,907 ms
269,564 KB |
testcase_14 | AC | 2,788 ms
269,480 KB |
testcase_15 | AC | 1,933 ms
269,520 KB |
testcase_16 | AC | 1,285 ms
268,020 KB |
testcase_17 | AC | 55 ms
66,304 KB |
testcase_18 | AC | 53 ms
64,512 KB |
testcase_19 | AC | 1,023 ms
267,064 KB |
testcase_20 | AC | 2,573 ms
269,464 KB |
testcase_21 | AC | 2,205 ms
280,160 KB |
testcase_22 | AC | 2,477 ms
269,576 KB |
testcase_23 | AC | 138 ms
85,416 KB |
testcase_24 | AC | 269 ms
105,308 KB |
testcase_25 | AC | 35 ms
52,608 KB |
ソースコード
# https://yukicoder.me/problems/no/2456 def solve(H, W, S, replica_cells, k): stamped_cell = [[0] * (W + 1) for _ in range(H + 1)] for h in range(k, H + 1): for w in range(k, W + 1): b = replica_cells[h][w] - replica_cells[h - k][w] - replica_cells[h][w - k] + replica_cells[h - k][w - k] if b == k ** 2: stamped_cell[h][w] += 1 stamped_cell[h - k][w] -= 1 stamped_cell[h][w - k] -= 1 stamped_cell[h - k][w - k] += 1 for h in range(H + 1): ans = 0 for w in reversed(range(W + 1)): ans += stamped_cell[h][w] stamped_cell[h][w] = ans for w in range(W + 1): ans = 0 for h in reversed(range(H + 1)): ans += stamped_cell[h][w] stamped_cell[h][w] = ans for h in range(H): for w in range(W): if S[h][w] == "#" and stamped_cell[h + 1][w + 1] == 0: return False elif S[h][w] == "." and stamped_cell[h + 1][w + 1] > 0: return False return True def main(): H, W = map(int, input().split()) S = [] for _ in range(H): S.append(input()) replica_cells = [[0] * (W + 1) for _ in range(H + 1)] for h in range(H): for w in range(W): if S[h][w] == "#": replica_cells[h + 1][w + 1] = 1 for h in range(H): row = 0 for w in range(W): row += replica_cells[h + 1][w + 1] replica_cells[h + 1][w + 1] = row + replica_cells[h][w + 1] low = 1 high = min(H, W) while high - low > 1: mid = (high + low) // 2 if solve(H, W, S, replica_cells, mid): low = mid else: high =mid if solve(H, W, S, replica_cells, high): print(high) else: print(low) if __name__ == "__main__": main()