結果

問題 No.179 塗り分け
ユーザー Ryushi-techRyushi-tech
提出日時 2020-06-24 23:26:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 3,000 ms
コード長 1,246 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 77,688 KB
最終ジャッジ日時 2023-09-30 21:28:25
合計ジャッジ時間 5,993 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,296 KB
testcase_01 AC 73 ms
71,524 KB
testcase_02 AC 73 ms
71,300 KB
testcase_03 AC 72 ms
71,332 KB
testcase_04 AC 74 ms
71,352 KB
testcase_05 AC 74 ms
71,368 KB
testcase_06 AC 74 ms
71,300 KB
testcase_07 AC 78 ms
75,764 KB
testcase_08 AC 82 ms
76,300 KB
testcase_09 AC 88 ms
76,468 KB
testcase_10 AC 86 ms
76,320 KB
testcase_11 AC 85 ms
76,440 KB
testcase_12 AC 112 ms
77,148 KB
testcase_13 AC 75 ms
71,532 KB
testcase_14 AC 75 ms
71,152 KB
testcase_15 AC 73 ms
71,372 KB
testcase_16 AC 74 ms
71,296 KB
testcase_17 AC 73 ms
71,368 KB
testcase_18 AC 92 ms
76,440 KB
testcase_19 AC 90 ms
76,508 KB
testcase_20 AC 76 ms
76,028 KB
testcase_21 AC 78 ms
75,628 KB
testcase_22 AC 120 ms
77,300 KB
testcase_23 AC 83 ms
76,636 KB
testcase_24 AC 117 ms
77,688 KB
testcase_25 AC 83 ms
76,380 KB
testcase_26 AC 106 ms
77,172 KB
testcase_27 AC 126 ms
77,196 KB
testcase_28 AC 109 ms
77,424 KB
testcase_29 AC 120 ms
77,504 KB
testcase_30 AC 124 ms
77,592 KB
testcase_31 AC 123 ms
77,388 KB
testcase_32 AC 107 ms
77,296 KB
testcase_33 AC 126 ms
77,596 KB
testcase_34 AC 112 ms
77,084 KB
testcase_35 AC 115 ms
77,184 KB
testcase_36 AC 71 ms
71,360 KB
testcase_37 AC 72 ms
71,404 KB
testcase_38 AC 75 ms
71,132 KB
testcase_39 AC 73 ms
71,348 KB
testcase_40 AC 73 ms
71,448 KB
testcase_41 AC 73 ms
71,484 KB
testcase_42 AC 73 ms
71,448 KB
testcase_43 AC 84 ms
76,228 KB
testcase_44 AC 90 ms
76,424 KB
testcase_45 AC 79 ms
76,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
S = []
for i in range(h):
    S.append(input())

cnt = 0
D = set()
for i in range(h):
    for j in range(w):
        if S[i][j] == "#":
            D.add(i * 1000 + j)

l = len(D)
if l & 1 or not D:
    print("NO")
    exit()
E = sorted(list(D))

for x in range(h):
    for y in range(w):
        tmp = set()
        cnt = 0
        for e in E:
            z = e + x * 1000 + y
            c, d = divmod(z, 1000)
            if e in tmp:
                continue
            elif c < 0 or c > h or d < 0 or d > w:
                break
            elif z in D:
                cnt += 1
                tmp.add(z)
        if l // 2 == cnt:
            print("YES")
            exit()
#print("turn2")
for x in range(h):
    for y in range(-1, -w, -1):
        tmp = set()
        cnt = 0
        for e in E:
            z = e + x * 1000 + y
            c, d = divmod(z, 1000)
            if e in tmp:
                continue
            elif c < 0 or c > h or d < 0 or d > w:
                break
            elif z in D:
                #print(e,z)
                cnt += 1
                tmp.add(z)
        if l // 2 == cnt:
            #print(cnt, tmp)
            print("YES")
            exit()
print("NO")
0