結果

問題 No.179 塗り分け
ユーザー NoneNone
提出日時 2021-05-01 09:31:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,240 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-07-19 15:48:04
合計ジャッジ時間 4,799 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,224 KB
testcase_01 AC 36 ms
51,968 KB
testcase_02 AC 37 ms
52,352 KB
testcase_03 AC 37 ms
52,480 KB
testcase_04 AC 37 ms
52,992 KB
testcase_05 AC 67 ms
75,688 KB
testcase_06 AC 45 ms
59,904 KB
testcase_07 WA -
testcase_08 AC 122 ms
77,292 KB
testcase_09 AC 124 ms
77,440 KB
testcase_10 AC 49 ms
62,124 KB
testcase_11 AC 50 ms
61,824 KB
testcase_12 AC 115 ms
76,928 KB
testcase_13 AC 42 ms
58,880 KB
testcase_14 AC 42 ms
59,520 KB
testcase_15 AC 36 ms
52,096 KB
testcase_16 AC 37 ms
52,480 KB
testcase_17 WA -
testcase_18 AC 103 ms
76,568 KB
testcase_19 AC 59 ms
70,912 KB
testcase_20 AC 118 ms
76,968 KB
testcase_21 AC 134 ms
77,156 KB
testcase_22 AC 164 ms
77,056 KB
testcase_23 AC 48 ms
61,952 KB
testcase_24 AC 159 ms
76,928 KB
testcase_25 AC 52 ms
64,768 KB
testcase_26 AC 97 ms
76,676 KB
testcase_27 AC 106 ms
77,248 KB
testcase_28 AC 99 ms
76,680 KB
testcase_29 AC 112 ms
77,312 KB
testcase_30 AC 116 ms
77,128 KB
testcase_31 AC 113 ms
77,184 KB
testcase_32 AC 106 ms
77,012 KB
testcase_33 AC 121 ms
77,000 KB
testcase_34 AC 111 ms
76,664 KB
testcase_35 AC 123 ms
77,180 KB
testcase_36 AC 37 ms
52,224 KB
testcase_37 AC 37 ms
52,736 KB
testcase_38 AC 36 ms
52,480 KB
testcase_39 AC 38 ms
52,480 KB
testcase_40 AC 37 ms
52,608 KB
testcase_41 AC 38 ms
52,352 KB
testcase_42 AC 38 ms
52,864 KB
testcase_43 AC 57 ms
71,936 KB
testcase_44 AC 69 ms
76,288 KB
testcase_45 AC 47 ms
61,696 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