結果

問題 No.179 塗り分け
ユーザー AEnAEn
提出日時 2022-05-13 14:09:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,040 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 78,816 KB
最終ジャッジ日時 2023-09-28 17:32:29
合計ジャッジ時間 8,761 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 77 ms
71,368 KB
testcase_02 AC 78 ms
71,260 KB
testcase_03 AC 77 ms
71,192 KB
testcase_04 AC 76 ms
71,188 KB
testcase_05 AC 78 ms
71,300 KB
testcase_06 AC 111 ms
76,956 KB
testcase_07 AC 80 ms
71,352 KB
testcase_08 WA -
testcase_09 AC 86 ms
76,144 KB
testcase_10 AC 131 ms
77,416 KB
testcase_11 AC 126 ms
77,788 KB
testcase_12 AC 211 ms
78,772 KB
testcase_13 AC 85 ms
75,736 KB
testcase_14 AC 78 ms
71,300 KB
testcase_15 AC 76 ms
71,512 KB
testcase_16 AC 77 ms
70,988 KB
testcase_17 AC 75 ms
71,460 KB
testcase_18 WA -
testcase_19 AC 137 ms
77,548 KB
testcase_20 AC 79 ms
71,368 KB
testcase_21 AC 78 ms
71,200 KB
testcase_22 AC 316 ms
78,396 KB
testcase_23 AC 194 ms
77,892 KB
testcase_24 AC 338 ms
77,972 KB
testcase_25 AC 302 ms
77,536 KB
testcase_26 AC 129 ms
77,664 KB
testcase_27 AC 148 ms
78,376 KB
testcase_28 AC 129 ms
77,684 KB
testcase_29 AC 153 ms
77,776 KB
testcase_30 AC 125 ms
77,836 KB
testcase_31 AC 153 ms
78,816 KB
testcase_32 AC 128 ms
77,504 KB
testcase_33 AC 158 ms
78,364 KB
testcase_34 AC 124 ms
77,972 KB
testcase_35 AC 156 ms
78,160 KB
testcase_36 AC 78 ms
71,212 KB
testcase_37 AC 75 ms
71,176 KB
testcase_38 AC 78 ms
71,512 KB
testcase_39 AC 77 ms
71,172 KB
testcase_40 AC 75 ms
71,300 KB
testcase_41 AC 77 ms
71,296 KB
testcase_42 AC 76 ms
71,288 KB
testcase_43 AC 98 ms
76,736 KB
testcase_44 AC 129 ms
77,600 KB
testcase_45 AC 86 ms
75,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
c = []
cnt = 0
for _ in range(H):
    s = list(input())
    cnt += s.count('#')
    c.append(s)
if cnt == 0 or cnt%2==1:
    print('NO')
    exit()

def solve(i, j):
    w1, w2 = [], []
    w1.append([0, H, 1])
    w2.append([0, W, 1])
    w1.append([H-1, -1, -1])
    w2.append([W-1, -1, -1])
    p, q = w1[i<0], w2[j<0]
    b = set()
    for x in range(p[0], p[1], p[2]):
        for y in range(q[0], q[1], q[2]):
            if x+i<0 or x+i>H-1 or y+j<0 or y+j>W-1:
                if (x, y) not in b and c[x][y]=='#':
                    return False
                else:
                    continue
            if (x, y) in b or c[x][y] == '.':
                continue
            b.add((x, y))
            if c[x+i][y+j]=='.':
                return False
            else:
                b.add((x+i, y+j))
    return True

for i in range(-H+1, H):
    for j in range(-W+1, W):
        if i == j:
            continue
        if solve(i, j):
            print('YES')
            exit()
print('NO')
0