結果

問題 No.179 塗り分け
ユーザー NoneNone
提出日時 2021-05-01 09:31:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,240 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 78,540 KB
最終ジャッジ日時 2023-09-26 22:00:37
合計ジャッジ時間 7,526 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,300 KB
testcase_01 AC 69 ms
71,300 KB
testcase_02 AC 70 ms
71,400 KB
testcase_03 AC 70 ms
71,412 KB
testcase_04 AC 67 ms
71,324 KB
testcase_05 AC 116 ms
77,072 KB
testcase_06 AC 80 ms
75,716 KB
testcase_07 WA -
testcase_08 AC 149 ms
78,444 KB
testcase_09 AC 154 ms
78,496 KB
testcase_10 AC 84 ms
76,236 KB
testcase_11 AC 84 ms
76,200 KB
testcase_12 AC 148 ms
77,812 KB
testcase_13 AC 73 ms
75,172 KB
testcase_14 AC 74 ms
75,540 KB
testcase_15 AC 71 ms
71,280 KB
testcase_16 AC 72 ms
71,260 KB
testcase_17 WA -
testcase_18 AC 127 ms
78,296 KB
testcase_19 AC 91 ms
76,472 KB
testcase_20 AC 145 ms
78,168 KB
testcase_21 AC 157 ms
78,476 KB
testcase_22 AC 184 ms
78,184 KB
testcase_23 AC 82 ms
76,032 KB
testcase_24 AC 184 ms
78,372 KB
testcase_25 AC 82 ms
76,580 KB
testcase_26 AC 122 ms
77,912 KB
testcase_27 AC 131 ms
78,268 KB
testcase_28 AC 126 ms
77,776 KB
testcase_29 AC 137 ms
78,408 KB
testcase_30 AC 146 ms
78,080 KB
testcase_31 AC 141 ms
78,316 KB
testcase_32 AC 134 ms
78,144 KB
testcase_33 AC 143 ms
78,272 KB
testcase_34 AC 139 ms
78,388 KB
testcase_35 AC 141 ms
78,540 KB
testcase_36 AC 68 ms
71,336 KB
testcase_37 AC 69 ms
71,404 KB
testcase_38 AC 69 ms
71,416 KB
testcase_39 AC 66 ms
71,404 KB
testcase_40 AC 65 ms
71,456 KB
testcase_41 AC 68 ms
71,400 KB
testcase_42 AC 67 ms
71,320 KB
testcase_43 AC 86 ms
76,280 KB
testcase_44 AC 89 ms
76,924 KB
testcase_45 AC 76 ms
75,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(grid):
    for h0 in range(H):
        for w0 in range(W):
            if (h0,w0)==(0,0):
                continue
            flg=0
            used=[[0]*W for _ in range(H)]
            for h in range(H):
                for w in range(W):
                    if grid[h][w]==".":
                        continue
                    if grid[h][w]=="#":
                        if used[h][w]==1:
                            continue
                        if not (h+h0<0 or w+w0<0 or h+h0>=H or w+w0>=W or grid[h+h0][w+w0]=="."):
                            used[h+h0][w+w0]=1
                            continue
                    flg=1
                    break
                if flg==1:
                    break
            if flg==0:
                return True
    return False


H,W=map(int,input().split())
grid=[[0]*W for _ in range(H)]
cnt=0
for h in range(H):
    for w,s in enumerate(input().rstrip()):
        grid[h][w]=s
        if s=="#":
            cnt+=1

if cnt==0:
    print("YES")
    exit()

res=0

res|=solve(grid)

for h in range(H):
    grid[h].reverse()

res|=solve(grid)

grid.reverse()

res|=solve(grid)

for h in range(H):
    grid[h].reverse()


res|=solve(grid)

print("YES" if res else "NO")
0