結果

問題 No.179 塗り分け
ユーザー NoneNone
提出日時 2021-05-01 09:32:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 184 ms / 3,000 ms
コード長 1,239 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 78,636 KB
最終ジャッジ日時 2023-09-26 22:02:37
合計ジャッジ時間 7,298 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,348 KB
testcase_01 AC 68 ms
71,324 KB
testcase_02 AC 69 ms
71,244 KB
testcase_03 AC 70 ms
71,360 KB
testcase_04 AC 69 ms
71,368 KB
testcase_05 AC 126 ms
76,992 KB
testcase_06 AC 76 ms
75,852 KB
testcase_07 AC 72 ms
75,668 KB
testcase_08 AC 145 ms
78,500 KB
testcase_09 AC 144 ms
78,376 KB
testcase_10 AC 79 ms
76,144 KB
testcase_11 AC 79 ms
76,016 KB
testcase_12 AC 137 ms
78,004 KB
testcase_13 AC 72 ms
75,240 KB
testcase_14 AC 72 ms
75,664 KB
testcase_15 AC 66 ms
71,432 KB
testcase_16 AC 67 ms
71,560 KB
testcase_17 AC 69 ms
71,292 KB
testcase_18 AC 120 ms
78,288 KB
testcase_19 AC 83 ms
76,448 KB
testcase_20 AC 140 ms
78,332 KB
testcase_21 AC 156 ms
78,416 KB
testcase_22 AC 173 ms
78,268 KB
testcase_23 AC 79 ms
76,228 KB
testcase_24 AC 184 ms
78,372 KB
testcase_25 AC 79 ms
76,860 KB
testcase_26 AC 119 ms
77,924 KB
testcase_27 AC 126 ms
78,500 KB
testcase_28 AC 126 ms
77,780 KB
testcase_29 AC 132 ms
78,372 KB
testcase_30 AC 140 ms
78,236 KB
testcase_31 AC 135 ms
78,236 KB
testcase_32 AC 125 ms
78,068 KB
testcase_33 AC 144 ms
78,636 KB
testcase_34 AC 139 ms
78,076 KB
testcase_35 AC 133 ms
78,608 KB
testcase_36 AC 66 ms
71,280 KB
testcase_37 AC 69 ms
71,152 KB
testcase_38 AC 69 ms
71,300 KB
testcase_39 AC 76 ms
71,252 KB
testcase_40 AC 70 ms
71,272 KB
testcase_41 AC 71 ms
71,560 KB
testcase_42 AC 67 ms
71,620 KB
testcase_43 AC 84 ms
76,564 KB
testcase_44 AC 89 ms
77,120 KB
testcase_45 AC 79 ms
75,932 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("NO")
    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