結果

問題 No.3804 Crossword Key Filler
コンテスト
ユーザー titia
提出日時 2026-11-18 06:02:51
言語 Python3
(3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 25 ms / 2,000 ms
+ 463µs
コード長 779 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 65 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2026-11-18 06:02:56
合計ジャッジ時間 4,555 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

H,W=list(map(int,input().split()))

MAP=[list(input().strip()) for i in range(H)]

ANS=set()

for i in range(H):
    for j in range(W):
        if MAP[i][j]==".":
            if i+1<H and MAP[i+1][j]==".":
                if i==0 or MAP[i-1][j]=="#":
                    ANS.add((i,j))

            if j+1<W and MAP[i][j+1]==".":
                if j==0 or MAP[i][j-1]=="#":
                    ANS.add((i,j))

ANS=sorted(ANS)

K=int(input())

for tests in range(K):
    d,com,s=input().split()

    x,y=ANS[int(d)-1]

    if com=="0":
        for j in range(len(s)):
            MAP[x][y+j]=s[j]
    else:
        for j in range(len(s)):
            MAP[x+j][y]=s[j]

    for ans in MAP:
        print("".join(ans))

    
                
0