結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー 👑 H20H20
提出日時 2022-03-13 13:44:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 44 ms / 1,000 ms
コード長 1,407 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 8,732 KB
最終ジャッジ日時 2023-09-10 16:31:57
合計ジャッジ時間 2,131 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,044 KB
testcase_01 AC 16 ms
8,296 KB
testcase_02 AC 16 ms
7,960 KB
testcase_03 AC 16 ms
8,032 KB
testcase_04 AC 15 ms
8,220 KB
testcase_05 AC 16 ms
8,040 KB
testcase_06 AC 15 ms
8,140 KB
testcase_07 AC 16 ms
8,432 KB
testcase_08 AC 16 ms
8,416 KB
testcase_09 AC 16 ms
8,408 KB
testcase_10 AC 16 ms
8,200 KB
testcase_11 AC 17 ms
8,076 KB
testcase_12 AC 16 ms
8,052 KB
testcase_13 AC 44 ms
8,448 KB
testcase_14 AC 16 ms
8,048 KB
testcase_15 AC 16 ms
8,292 KB
testcase_16 AC 16 ms
8,352 KB
testcase_17 AC 16 ms
8,492 KB
testcase_18 AC 17 ms
8,036 KB
testcase_19 AC 16 ms
8,504 KB
testcase_20 AC 16 ms
8,032 KB
testcase_21 AC 33 ms
8,564 KB
testcase_22 AC 43 ms
8,460 KB
testcase_23 AC 17 ms
8,140 KB
testcase_24 AC 24 ms
8,600 KB
testcase_25 AC 43 ms
8,648 KB
testcase_26 AC 16 ms
8,044 KB
testcase_27 AC 41 ms
8,732 KB
testcase_28 AC 40 ms
8,568 KB
testcase_29 AC 16 ms
8,384 KB
testcase_30 AC 41 ms
8,532 KB
testcase_31 AC 16 ms
8,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int, input().split())
MAP = []
for _ in range(H):
    MAP.append(list(input()))
M = int(input())
TN = [list(map(int, input().split())) for _ in range(M)]
R = [0]
C = [0]
for t,n in TN:
    if t==1 and n!=H:
        R.append(n)
    if t==2 and n!=W:
        C.append(n)
R.sort()
C.sort()
RS = set(R)
CS = set(C)
for i in range(H):
    for j in range(W):
        if (i+j)%2==1:
            if MAP[i][j]=='.':
                MAP[i][j]='#'
            else:
                MAP[i][j]='.'
for i in range(H):
    for j in range(W-1):
        if MAP[i][j]!=MAP[i][j+1] and not j+1 in CS:
            print('No')
            exit()
for i in range(H-1):
    for j in range(W):
        if MAP[i][j]!=MAP[i+1][j] and not i+1 in RS:
            print('No')
            exit()
MAP2 = []
for r in R:
    L = []
    for c in C:
        L.append(MAP[r][c])
    MAP2.append(L)
H2 = len(MAP2)
W2 = len(MAP2[0])
for i in range(H2):
    if MAP2[i][0]=='#':
        for j in range(W2):
            if MAP2[i][j]=='.':
                MAP2[i][j]='#'
            else:
                MAP2[i][j]='.'
for i in range(W2):
    if MAP2[0][i]=='#':
        for j in range(H2):
            if MAP2[j][i]=='.':
                MAP2[j][i]='#'
            else:
                MAP2[j][i]='.'
for i in range(H2):
    for j in range(W2):
        if MAP2[i][j]!=MAP2[0][0]:
            print('No')
            exit()
print('Yes')
0