結果

問題 No.179 塗り分け
ユーザー AEnAEn
提出日時 2022-05-13 14:13:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 361 ms / 3,000 ms
コード長 1,045 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 86,404 KB
実行使用メモリ 78,796 KB
最終ジャッジ日時 2023-09-28 17:37:02
合計ジャッジ時間 9,198 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,244 KB
testcase_01 AC 76 ms
71,304 KB
testcase_02 AC 77 ms
71,136 KB
testcase_03 AC 76 ms
71,052 KB
testcase_04 AC 79 ms
71,192 KB
testcase_05 AC 78 ms
70,944 KB
testcase_06 AC 116 ms
76,872 KB
testcase_07 AC 76 ms
71,364 KB
testcase_08 AC 82 ms
75,812 KB
testcase_09 AC 88 ms
75,720 KB
testcase_10 AC 135 ms
77,860 KB
testcase_11 AC 129 ms
77,452 KB
testcase_12 AC 216 ms
78,744 KB
testcase_13 AC 85 ms
75,520 KB
testcase_14 AC 80 ms
71,080 KB
testcase_15 AC 78 ms
71,080 KB
testcase_16 AC 77 ms
71,120 KB
testcase_17 AC 77 ms
71,240 KB
testcase_18 AC 139 ms
77,424 KB
testcase_19 AC 136 ms
77,564 KB
testcase_20 AC 78 ms
70,924 KB
testcase_21 AC 79 ms
70,976 KB
testcase_22 AC 323 ms
78,596 KB
testcase_23 AC 200 ms
78,016 KB
testcase_24 AC 361 ms
78,292 KB
testcase_25 AC 320 ms
77,528 KB
testcase_26 AC 127 ms
77,520 KB
testcase_27 AC 148 ms
78,200 KB
testcase_28 AC 128 ms
77,644 KB
testcase_29 AC 156 ms
78,256 KB
testcase_30 AC 124 ms
77,872 KB
testcase_31 AC 157 ms
78,536 KB
testcase_32 AC 124 ms
77,484 KB
testcase_33 AC 162 ms
78,796 KB
testcase_34 AC 122 ms
77,492 KB
testcase_35 AC 154 ms
77,708 KB
testcase_36 AC 76 ms
71,264 KB
testcase_37 AC 77 ms
70,968 KB
testcase_38 AC 79 ms
71,436 KB
testcase_39 AC 78 ms
71,264 KB
testcase_40 AC 77 ms
71,096 KB
testcase_41 AC 78 ms
71,364 KB
testcase_42 AC 78 ms
71,456 KB
testcase_43 AC 104 ms
76,752 KB
testcase_44 AC 131 ms
77,684 KB
testcase_45 AC 82 ms
75,720 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 == 0:
            continue
        if solve(i, j):
            print('YES')
            exit()
print('NO')
0