結果

問題 No.179 塗り分け
ユーザー ssmkzkssmkzk
提出日時 2019-03-13 02:56:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,501 ms / 3,000 ms
コード長 1,331 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 8,412 KB
最終ジャッジ日時 2023-09-30 21:07:47
合計ジャッジ時間 4,742 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,252 KB
testcase_01 AC 16 ms
8,340 KB
testcase_02 AC 16 ms
8,136 KB
testcase_03 AC 16 ms
7,788 KB
testcase_04 AC 16 ms
8,308 KB
testcase_05 AC 16 ms
8,252 KB
testcase_06 AC 16 ms
8,196 KB
testcase_07 AC 16 ms
8,200 KB
testcase_08 AC 23 ms
8,296 KB
testcase_09 AC 25 ms
8,168 KB
testcase_10 AC 18 ms
8,328 KB
testcase_11 AC 18 ms
8,260 KB
testcase_12 AC 1,501 ms
8,168 KB
testcase_13 AC 17 ms
7,888 KB
testcase_14 AC 17 ms
7,792 KB
testcase_15 AC 16 ms
8,184 KB
testcase_16 AC 16 ms
8,328 KB
testcase_17 AC 16 ms
8,244 KB
testcase_18 AC 19 ms
8,276 KB
testcase_19 AC 18 ms
8,296 KB
testcase_20 AC 17 ms
8,248 KB
testcase_21 AC 17 ms
8,304 KB
testcase_22 AC 39 ms
8,288 KB
testcase_23 AC 17 ms
8,328 KB
testcase_24 AC 33 ms
8,252 KB
testcase_25 AC 17 ms
8,188 KB
testcase_26 AC 21 ms
8,180 KB
testcase_27 AC 65 ms
8,288 KB
testcase_28 AC 20 ms
8,312 KB
testcase_29 AC 97 ms
8,276 KB
testcase_30 AC 52 ms
8,320 KB
testcase_31 AC 127 ms
8,304 KB
testcase_32 AC 43 ms
8,256 KB
testcase_33 AC 160 ms
8,252 KB
testcase_34 AC 35 ms
8,412 KB
testcase_35 AC 193 ms
8,340 KB
testcase_36 AC 16 ms
7,792 KB
testcase_37 AC 16 ms
8,332 KB
testcase_38 AC 16 ms
7,952 KB
testcase_39 AC 16 ms
7,936 KB
testcase_40 AC 16 ms
7,792 KB
testcase_41 AC 16 ms
8,336 KB
testcase_42 AC 17 ms
7,836 KB
testcase_43 AC 19 ms
7,884 KB
testcase_44 AC 27 ms
7,792 KB
testcase_45 AC 17 ms
7,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

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

black_l = []
count = 0

for i in range(H):
    l = list(input())
    for j in range(W):
        if l[j] == "#":
            black_l.append(H * i + j)
            count += 1

if count == 0:
    print("NO")
    sys.exit()

if count % 2 == 0:
    num = count // 2
else:
    print("NO")
    sys.exit()

for i in range(H):
    for j in range(W):
        if i == j == 0:
            continue
        nowuse = list(black_l)
        nowuse1 = list(black_l)
        while True:
            if (nowuse[0] % H) + j > W - 1:
                break
            ck_nom = nowuse[0] + j + i * H
            try:
                nowuse.remove(ck_nom)
                nowuse.pop(0)
            except:
                # print(i,j)
                # print(nowuse)
                break
            if len(nowuse) == 0:
                print("YES")
                sys.exit()
        while True:
            if (nowuse1[0] % H) - j < 0:
                break
            ck_nom = nowuse1[0] - j + i * H
            try:
                nowuse1.remove(ck_nom)
                nowuse1.pop(0)
            except:
                # print(i,j)
                # print(nowuse)
                break
            if len(nowuse1) == 0:
                print("YES")
                sys.exit()        

print("NO")

0