結果

問題 No.179 塗り分け
ユーザー nbisconbisco
提出日時 2017-02-24 00:49:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,237 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-14 06:16:40
合計ジャッジ時間 7,405 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
11,008 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 30 ms
11,008 KB
testcase_05 AC 30 ms
11,008 KB
testcase_06 WA -
testcase_07 AC 30 ms
10,880 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 30 ms
10,880 KB
testcase_11 AC 30 ms
10,880 KB
testcase_12 AC 769 ms
10,880 KB
testcase_13 AC 31 ms
10,880 KB
testcase_14 AC 30 ms
10,880 KB
testcase_15 AC 29 ms
10,880 KB
testcase_16 WA -
testcase_17 AC 30 ms
10,880 KB
testcase_18 AC 39 ms
10,880 KB
testcase_19 WA -
testcase_20 AC 30 ms
10,880 KB
testcase_21 AC 30 ms
11,008 KB
testcase_22 AC 78 ms
10,880 KB
testcase_23 WA -
testcase_24 AC 63 ms
10,880 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 219 ms
10,880 KB
testcase_28 WA -
testcase_29 AC 342 ms
10,880 KB
testcase_30 WA -
testcase_31 AC 445 ms
10,880 KB
testcase_32 AC 124 ms
10,880 KB
testcase_33 AC 449 ms
10,880 KB
testcase_34 WA -
testcase_35 AC 542 ms
10,880 KB
testcase_36 AC 30 ms
10,880 KB
testcase_37 AC 31 ms
10,880 KB
testcase_38 AC 29 ms
10,880 KB
testcase_39 AC 30 ms
10,880 KB
testcase_40 AC 30 ms
10,880 KB
testcase_41 AC 30 ms
10,880 KB
testcase_42 AC 29 ms
10,880 KB
testcase_43 AC 37 ms
10,880 KB
testcase_44 AC 68 ms
10,880 KB
testcase_45 AC 31 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def move_ok(_S, H, W, count, diff):
    S = [[_S[i][j] for j in range(W)] for i in range(H)]
    for i in range(H):
        for j in range(W):
            if S[i][j] == ".":
                continue
            elif i+diff[0] < H and j+diff[1] < W \
                and S[i+diff[0]][j+diff[1]] == "#":
                count -= 2
                S[i+diff[0]][j+diff[1]] = "."
    return count == 0

def main():
    H, W = map(int, input().split(" "))
    S = []
    for i in range(H):
        S.append(list(input()))
    start = [-1,-1]
    count = 0
    for i in range(H):
        count += S[i].count("#")
        if start[0] != -1:
            for j in range(W):
                if S[i][j] == "#":
                    start[0] = i
                    start[1] = j
                    break

    if count % 2 != 0:
        print("NO")
        return

    for i in range(start[0], H):
        for j in range(W):
            if start[0] == i and start[1] == j:
                continue
            if S[i][j] == ".":
                continue
            diff = (i-start[0], j-start[1])
            if move_ok(S, H, W, count, diff):
                print("YES")
                return
    print("NO")

if __name__ == "__main__":
    main()
0