結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー 👑 H20H20
提出日時 2022-02-16 00:47:44
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 89 ms / 1,000 ms
コード長 1,407 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 76,296 KB
最終ジャッジ日時 2023-09-10 16:31:54
合計ジャッジ時間 5,336 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,288 KB
testcase_01 AC 71 ms
71,460 KB
testcase_02 AC 71 ms
71,344 KB
testcase_03 AC 70 ms
71,456 KB
testcase_04 AC 70 ms
71,192 KB
testcase_05 AC 72 ms
71,148 KB
testcase_06 AC 73 ms
71,344 KB
testcase_07 AC 72 ms
71,464 KB
testcase_08 AC 72 ms
71,516 KB
testcase_09 AC 71 ms
71,080 KB
testcase_10 AC 72 ms
71,620 KB
testcase_11 AC 73 ms
71,276 KB
testcase_12 AC 71 ms
71,256 KB
testcase_13 AC 86 ms
76,248 KB
testcase_14 AC 73 ms
71,080 KB
testcase_15 AC 72 ms
71,280 KB
testcase_16 AC 73 ms
71,504 KB
testcase_17 AC 72 ms
71,420 KB
testcase_18 AC 73 ms
71,336 KB
testcase_19 AC 73 ms
71,236 KB
testcase_20 AC 75 ms
71,552 KB
testcase_21 AC 85 ms
76,156 KB
testcase_22 AC 88 ms
76,148 KB
testcase_23 AC 74 ms
71,504 KB
testcase_24 AC 80 ms
76,112 KB
testcase_25 AC 86 ms
76,296 KB
testcase_26 AC 72 ms
71,524 KB
testcase_27 AC 89 ms
76,272 KB
testcase_28 AC 86 ms
76,140 KB
testcase_29 AC 71 ms
71,348 KB
testcase_30 AC 88 ms
76,208 KB
testcase_31 AC 72 ms
71,464 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