結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー 👑 H20H20
提出日時 2022-04-10 18:18:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 1,000 ms
コード長 1,790 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 76,196 KB
最終ジャッジ日時 2023-09-10 16:32:09
合計ジャッジ時間 4,032 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,292 KB
testcase_01 AC 72 ms
71,328 KB
testcase_02 AC 71 ms
71,360 KB
testcase_03 AC 70 ms
71,300 KB
testcase_04 AC 70 ms
71,100 KB
testcase_05 AC 72 ms
71,296 KB
testcase_06 AC 73 ms
71,280 KB
testcase_07 AC 70 ms
71,360 KB
testcase_08 AC 71 ms
71,408 KB
testcase_09 AC 71 ms
71,352 KB
testcase_10 AC 72 ms
71,156 KB
testcase_11 AC 73 ms
71,344 KB
testcase_12 AC 71 ms
71,424 KB
testcase_13 AC 84 ms
75,944 KB
testcase_14 AC 74 ms
71,304 KB
testcase_15 AC 75 ms
71,304 KB
testcase_16 AC 74 ms
71,172 KB
testcase_17 AC 73 ms
71,496 KB
testcase_18 AC 73 ms
71,292 KB
testcase_19 AC 73 ms
71,332 KB
testcase_20 AC 74 ms
71,428 KB
testcase_21 AC 83 ms
76,000 KB
testcase_22 AC 89 ms
76,016 KB
testcase_23 AC 74 ms
71,360 KB
testcase_24 AC 81 ms
75,808 KB
testcase_25 AC 88 ms
76,124 KB
testcase_26 AC 73 ms
71,312 KB
testcase_27 AC 89 ms
76,108 KB
testcase_28 AC 88 ms
76,088 KB
testcase_29 AC 72 ms
71,428 KB
testcase_30 AC 87 ms
76,196 KB
testcase_31 AC 72 ms
71,440 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)]

if not(2<=H<=200 and 2<=W<=200 and 0<=M<=23):
    exit()

if len(MAP)!=H:
    exit()
for m in MAP:
    if len(m)==W and m.count('#')+m.count('.')==W:
        continue
    exit()
S = set()
for t,n in TN:
    S.add((t,n))
    if t==1:
        if 1<=n<=H:
            continue
    elif t==2:
        if 1<=n<=W:
            continue
    exit()
if len(S)!=M or len(TN)!=M:
    exit()


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