結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー tktk_snsntktk_snsn
提出日時 2022-05-21 00:12:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 42 ms / 1,000 ms
コード長 1,074 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 10,756 KB
最終ジャッジ日時 2023-10-20 15:05:53
合計ジャッジ時間 2,509 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,244 KB
testcase_01 AC 27 ms
10,244 KB
testcase_02 AC 28 ms
10,244 KB
testcase_03 AC 29 ms
10,244 KB
testcase_04 AC 28 ms
10,244 KB
testcase_05 AC 27 ms
10,244 KB
testcase_06 AC 27 ms
10,244 KB
testcase_07 AC 29 ms
10,244 KB
testcase_08 AC 28 ms
10,244 KB
testcase_09 AC 29 ms
10,244 KB
testcase_10 AC 29 ms
10,244 KB
testcase_11 AC 28 ms
10,244 KB
testcase_12 AC 27 ms
10,244 KB
testcase_13 AC 41 ms
10,756 KB
testcase_14 AC 28 ms
10,252 KB
testcase_15 AC 27 ms
10,252 KB
testcase_16 AC 29 ms
10,252 KB
testcase_17 AC 30 ms
10,252 KB
testcase_18 AC 28 ms
10,252 KB
testcase_19 AC 28 ms
10,272 KB
testcase_20 AC 30 ms
10,272 KB
testcase_21 AC 41 ms
10,756 KB
testcase_22 AC 39 ms
10,756 KB
testcase_23 AC 28 ms
10,268 KB
testcase_24 AC 40 ms
10,756 KB
testcase_25 AC 40 ms
10,756 KB
testcase_26 AC 28 ms
10,248 KB
testcase_27 AC 40 ms
10,756 KB
testcase_28 AC 41 ms
10,756 KB
testcase_29 AC 29 ms
10,248 KB
testcase_30 AC 42 ms
10,756 KB
testcase_31 AC 29 ms
10,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
S = [[int(s == "#") for s in input()] for _ in range(H)]
M = int(input())
row = set()
col = set()
for _ in range(M):
    t, n = map(int, input().split())
    if t == 1:
        row.add(n)
    else:
        col.add(n)


def solve(flip=0):
    X = [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            target = flip
            if (i + j) % 2 == 0:
                target ^= 1
            X[i][j] = target ^ S[i][j]

    memo = set()
    for i in range(H):
        memo.add(tuple(X[i]))

    if len(memo) > 2:
        return False
    if len(memo) == 2:
        a = memo.pop()
        b = memo.pop()
        for i in range(W):
            if a[i] != b[i] ^ 1:
                return False
        for i in range(1, H):
            if X[i][0] != X[i-1][0]:
                if not i in row:
                    return False
    for i in range(1, W):
        if X[0][i] != X[0][i-1]:
            if not i in col:
                return False
    return True


if solve():
    print("Yes")
else:
    print("No")
0