結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー titiatitia
提出日時 2022-05-22 03:45:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 1,029 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 11,968 KB
実行使用メモリ 10,380 KB
最終ジャッジ日時 2023-10-20 16:49:09
合計ジャッジ時間 2,504 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,144 KB
testcase_01 AC 27 ms
10,144 KB
testcase_02 AC 26 ms
10,144 KB
testcase_03 AC 26 ms
10,144 KB
testcase_04 AC 25 ms
10,144 KB
testcase_05 AC 26 ms
10,144 KB
testcase_06 AC 26 ms
10,144 KB
testcase_07 AC 26 ms
10,144 KB
testcase_08 AC 26 ms
10,144 KB
testcase_09 AC 26 ms
10,144 KB
testcase_10 AC 26 ms
10,144 KB
testcase_11 AC 28 ms
10,144 KB
testcase_12 AC 27 ms
10,144 KB
testcase_13 AC 56 ms
10,380 KB
testcase_14 AC 28 ms
10,148 KB
testcase_15 AC 27 ms
10,148 KB
testcase_16 AC 27 ms
10,148 KB
testcase_17 AC 27 ms
10,148 KB
testcase_18 AC 26 ms
10,148 KB
testcase_19 AC 26 ms
10,168 KB
testcase_20 AC 27 ms
10,168 KB
testcase_21 AC 55 ms
10,380 KB
testcase_22 AC 57 ms
10,380 KB
testcase_23 AC 28 ms
10,164 KB
testcase_24 AC 53 ms
10,380 KB
testcase_25 AC 53 ms
10,380 KB
testcase_26 AC 27 ms
10,144 KB
testcase_27 AC 57 ms
10,380 KB
testcase_28 AC 54 ms
10,380 KB
testcase_29 AC 27 ms
10,144 KB
testcase_30 AC 56 ms
10,380 KB
testcase_31 AC 28 ms
10,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from collections import Counter

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

A=[[0]*W for i in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            A[i][j]=1


for i in range(H):
    for j in range(W):
        if (i+j)%2==1:
            A[i][j]^=1

#for a in A:
#    print(*a)

OP=int(input())

ONE=[]
TWO=[]

for i in range(OP):
    x,y=map(int,input().split())
    if x==1:
        ONE.append(y)
    else:
        TWO.append(y)

ONEX=[]
TWOX=[]

for i in range(1,H):
    for j in range(W):
        if A[i][j]!=A[i-1][j]:
            ONEX.append(i)

for i in range(H):
    for j in range(1,W):
        if A[i][j]!=A[i][j-1]:
            TWOX.append(j)

OC=Counter(ONEX)

for v in OC.values():
    if v!=W:
        print("No")
        exit()

TC=Counter(TWOX)

for v in TC.values():
    if v!=H:
        print("No")
        exit()


if set(ONEX)<=set(ONE) and set(TWOX)<=set(TWO):
    print("Yes")
else:
    print("No")
        
0