結果

問題 No.2641 draw X
ユーザー ponjuiceponjuice
提出日時 2024-02-11 18:09:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 456 ms / 2,000 ms
コード長 1,349 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 123,864 KB
最終ジャッジ日時 2024-02-13 14:53:33
合計ジャッジ時間 8,786 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 41 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 37 ms
53,460 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 39 ms
53,460 KB
testcase_13 AC 37 ms
53,460 KB
testcase_14 AC 38 ms
53,460 KB
testcase_15 AC 183 ms
123,864 KB
testcase_16 AC 344 ms
122,328 KB
testcase_17 AC 37 ms
53,460 KB
testcase_18 AC 37 ms
53,460 KB
testcase_19 AC 37 ms
53,460 KB
testcase_20 AC 131 ms
80,140 KB
testcase_21 AC 133 ms
83,056 KB
testcase_22 AC 138 ms
79,876 KB
testcase_23 AC 118 ms
83,052 KB
testcase_24 AC 88 ms
78,616 KB
testcase_25 AC 92 ms
78,128 KB
testcase_26 AC 147 ms
83,672 KB
testcase_27 AC 129 ms
78,740 KB
testcase_28 AC 138 ms
94,792 KB
testcase_29 AC 158 ms
104,616 KB
testcase_30 AC 181 ms
105,000 KB
testcase_31 AC 178 ms
97,912 KB
testcase_32 AC 214 ms
114,856 KB
testcase_33 AC 325 ms
115,112 KB
testcase_34 AC 202 ms
100,504 KB
testcase_35 AC 212 ms
96,284 KB
testcase_36 AC 252 ms
120,152 KB
testcase_37 AC 456 ms
122,712 KB
testcase_38 AC 274 ms
117,848 KB
testcase_39 AC 285 ms
122,712 KB
testcase_40 AC 415 ms
121,816 KB
testcase_41 AC 249 ms
117,848 KB
testcase_42 AC 302 ms
119,768 KB
testcase_43 AC 287 ms
118,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
S = [input() for _ in range(H)]

mx1 = [[0]*(W+2) for _ in range(H+2)]
mx2 = [[0]*(W+2) for _ in range(H+2)]
mx3 = [[0]*(W+2) for _ in range(H+2)]
mx4 = [[0]*(W+2) for _ in range(H+2)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            mx1[i][j] = mx1[i-1][j-1] + 1
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            mx2[i][j] = mx2[i-1][j+1] + 1
for i in range(H-1,-1,-1):
    for j in range(W):
        if S[i][j] == '#':
            mx3[i][j] = mx3[i+1][j-1] + 1
for i in range(H-1,-1,-1):
    for j in range(W):
        if S[i][j] == '#':
            mx4[i][j] = mx4[i+1][j+1] + 1

imos1 = [[0]*(W+2) for _ in range(H+2)]
imos2 = [[0]*(W+2) for _ in range(H+2)]

for i in range(H):
    for j in range(W):
        r = min(mx1[i][j], mx2[i][j], mx3[i][j], mx4[i][j]) - 1
        if r <= 0:
            continue
        imos1[i - r][j - r]+=1
        imos1[i + r + 1][j + r + 1]-=1
        imos2[i - r][j + r]+=1
        imos2[i + r + 1][j - r - 1]-=1

for i in range(H):
    for j in range(W):
        imos1[i][j] += imos1[i - 1][j - 1]
        imos2[i][j] += imos2[i - 1][j + 1]

same = True
for i in range(H):
    for j in range(W):
        if S[i][j] == '#' and imos1[i][j] + imos2[i][j] == 0:
            same = False

print("Yes" if same else "No")
0