結果

問題 No.179 塗り分け
ユーザー ckawatakckawatak
提出日時 2017-07-27 23:20:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,179 ms / 3,000 ms
コード長 1,005 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 11,072 KB
実行使用メモリ 8,624 KB
最終ジャッジ日時 2023-09-30 20:56:19
合計ジャッジ時間 8,958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,340 KB
testcase_01 AC 16 ms
8,336 KB
testcase_02 AC 16 ms
8,284 KB
testcase_03 AC 16 ms
8,200 KB
testcase_04 AC 17 ms
8,288 KB
testcase_05 AC 16 ms
8,244 KB
testcase_06 AC 17 ms
8,220 KB
testcase_07 AC 16 ms
8,192 KB
testcase_08 AC 19 ms
8,204 KB
testcase_09 AC 22 ms
8,248 KB
testcase_10 AC 19 ms
8,624 KB
testcase_11 AC 18 ms
8,436 KB
testcase_12 AC 1,179 ms
8,432 KB
testcase_13 AC 16 ms
8,168 KB
testcase_14 AC 16 ms
8,352 KB
testcase_15 AC 15 ms
8,168 KB
testcase_16 AC 15 ms
8,192 KB
testcase_17 AC 16 ms
8,260 KB
testcase_18 AC 38 ms
8,492 KB
testcase_19 AC 37 ms
8,388 KB
testcase_20 AC 17 ms
8,300 KB
testcase_21 AC 17 ms
8,364 KB
testcase_22 AC 146 ms
8,332 KB
testcase_23 AC 18 ms
8,352 KB
testcase_24 AC 109 ms
8,376 KB
testcase_25 AC 18 ms
8,208 KB
testcase_26 AC 151 ms
8,292 KB
testcase_27 AC 419 ms
8,300 KB
testcase_28 AC 320 ms
8,516 KB
testcase_29 AC 656 ms
8,484 KB
testcase_30 AC 523 ms
8,336 KB
testcase_31 AC 759 ms
8,428 KB
testcase_32 AC 126 ms
8,392 KB
testcase_33 AC 764 ms
8,448 KB
testcase_34 AC 529 ms
8,444 KB
testcase_35 AC 899 ms
8,412 KB
testcase_36 AC 16 ms
8,168 KB
testcase_37 AC 16 ms
8,392 KB
testcase_38 AC 16 ms
8,168 KB
testcase_39 AC 17 ms
8,304 KB
testcase_40 AC 16 ms
8,192 KB
testcase_41 AC 16 ms
8,196 KB
testcase_42 AC 17 ms
8,364 KB
testcase_43 AC 27 ms
8,316 KB
testcase_44 AC 87 ms
8,292 KB
testcase_45 AC 19 ms
8,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = list(map(int, input().split(' ')))

blacks = {}
for h in range(H):
    boxes = input()
    for w in range(W):
        if boxes[w] == '#':
            blacks[(h,w)] = 0

if len(blacks) == 0 or len(blacks) % 2 != 0:
    print('NO')
    exit()

def check(i, j):
    yes = True
    for key in blacks.keys():
        blacks[key] = 0
    for (h,w) in sorted(blacks.keys()):
        if blacks[(h,w)] == 0:
            blacks[(h,w)] = 1
            if (h+i,w+j) not in blacks:
                yes = False
                break
            else:
                blacks[(h+i,w+j)] = 1
    if yes:
        print('YES')
        exit()    
    
# check from top to bottom
for i in range(1,H):
    check(i, 0)

# check from left to right
for j in range(1,W):
    check(0, j)

# check from upper left to lower right
for i in range(1,H):
    for j in range(1,W):
        check(i, j)

# check from upper right to lower left
for i in range(1,H):
    for j in range(1,W):
        check(i, -j)        

print('NO')    
0