結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー ああいいああいい
提出日時 2022-05-21 17:40:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,242 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 77,892 KB
最終ジャッジ日時 2023-10-20 16:27:12
合計ジャッジ時間 3,173 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,540 KB
testcase_01 AC 35 ms
53,540 KB
testcase_02 AC 36 ms
53,540 KB
testcase_03 AC 35 ms
53,540 KB
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 34 ms
53,540 KB
testcase_08 AC 34 ms
53,540 KB
testcase_09 AC 33 ms
53,540 KB
testcase_10 AC 34 ms
53,540 KB
testcase_11 AC 35 ms
53,540 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 35 ms
53,540 KB
testcase_17 AC 35 ms
53,540 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 49 ms
66,088 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 45 ms
66,088 KB
testcase_26 AC 33 ms
53,540 KB
testcase_27 AC 47 ms
66,096 KB
testcase_28 AC 49 ms
68,180 KB
testcase_29 AC 33 ms
53,540 KB
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

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 j 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