結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー ああいいああいい
提出日時 2022-05-21 17:42:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 1,000 ms
コード長 1,242 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 70,260 KB
最終ジャッジ日時 2023-10-20 16:27:28
合計ジャッジ時間 2,643 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,564 KB
testcase_01 AC 35 ms
53,564 KB
testcase_02 AC 36 ms
53,564 KB
testcase_03 AC 36 ms
53,564 KB
testcase_04 AC 35 ms
53,564 KB
testcase_05 AC 36 ms
53,564 KB
testcase_06 AC 37 ms
53,564 KB
testcase_07 AC 36 ms
53,564 KB
testcase_08 AC 36 ms
53,564 KB
testcase_09 AC 36 ms
53,564 KB
testcase_10 AC 36 ms
53,564 KB
testcase_11 AC 37 ms
53,564 KB
testcase_12 AC 36 ms
53,564 KB
testcase_13 AC 52 ms
66,112 KB
testcase_14 AC 38 ms
53,564 KB
testcase_15 AC 38 ms
53,564 KB
testcase_16 AC 37 ms
53,564 KB
testcase_17 AC 37 ms
53,564 KB
testcase_18 AC 38 ms
53,564 KB
testcase_19 AC 40 ms
55,612 KB
testcase_20 AC 40 ms
55,612 KB
testcase_21 AC 50 ms
66,092 KB
testcase_22 AC 59 ms
70,260 KB
testcase_23 AC 40 ms
53,564 KB
testcase_24 AC 58 ms
68,196 KB
testcase_25 AC 50 ms
66,092 KB
testcase_26 AC 37 ms
53,564 KB
testcase_27 AC 51 ms
66,100 KB
testcase_28 AC 54 ms
68,184 KB
testcase_29 AC 37 ms
53,564 KB
testcase_30 AC 58 ms
70,260 KB
testcase_31 AC 36 ms
53,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int,input().split())
S = [input() for _ in range(H)]
M = int(input())

yoko = set()
tate = set()
for _ in range(M):
    t,n = map(int,input().split())
    if t == 1:
        yoko.add(n - 1)
    else:
        tate.add(n - 1)
gyo = [[0] * W for _ in range(H - 1)]
retu = [[0] * (W - 1) for _ in range(H)]
for i in range(H - 1):
    for j in range(W):
        if S[i][j] == S[i + 1][j]:
            gyo[i][j] = 0
        else:
            gyo[i][j] = 1
for i in range(H):
    for j in range(W - 1):
        if S[i][j] == S[i][j + 1]:
            retu[i][j] = 0
        else:
            retu[i][j] = 1
import sys
for i in range(H - 1):
    zero = False
    one = False
    for j in range(W):
        if gyo[i][j] == 1:
            one = True
        else:
            zero = True
    if zero == one:
        print('No')
        exit()
    if zero:
        if i not in yoko:
            print('No')
            exit()
for j in range(W - 1):
    zero = False
    one = False
    for i in range(H):
        if retu[i][j] == 1:
            one = True
        else:
            zero = True
    if one == zero:
        print('No')
        exit()
    if zero:
        if j not in tate:
            print('No')
            exit()
print('Yes')
0