結果

問題 No.3804 Crossword Key Filler
コンテスト
ユーザー 👑 cologne
提出日時 2026-12-02 17:38:58
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 69 ms / 2,000 ms
+ 34µs
コード長 1,340 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 126 ms
コンパイル使用メモリ 64,256 KB
実行使用メモリ 62,120 KB
最終ジャッジ日時 2026-12-02 17:39:10
合計ジャッジ時間 6,265 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
from collections import deque, defaultdict
from typing import List, Tuple

sys.setrecursionlimit(10 ** 6)

MOD = 10 ** 9 + 7

int1 = lambda x: int(x) - 1
input = lambda: sys.stdin.readline().rstrip('\n')
ii = lambda: int(input())
vi = lambda: list(map(int, input().split()))
vi1 = lambda: list(map(int1, input().split()))


def dbg(*args, **kwargs):
    print(*(repr(arg) for arg in args), *(f'{k}: {repr(v)}' for k, v in kwargs.items()),
          sep='; ', file=sys.stderr, flush=True)


def calc(s):
    ret = []
    for i in range(len(s)):
        for j in range(len(s[i]) - 1):
            if (j == 0 or s[i][j - 1] == '#') and s[i][j] == '.' and s[i][j + 1] == '.':
                ret.append((i, j))
    return ret


def main():
    h, w = vi()
    s = [list(input()) for _ in range(h)]

    a = calc(s)
    b = calc(list(zip(*s)))
    clues = sorted(set(a + [(x, y) for y, x in b]))

    q = ii()
    for _ in range(q):
        k, d, a = input().split()
        k, d = int1(k), int(d)
        r, c = clues[k]
        for i in range(len(a)):
            s[r + d * i][c + (1 - d) * i] = a[i]
        for c in s:
            print(''.join(c))


def _start():
    if (ret := main()) is not None:
        print(*ret) if isinstance(ret, List) or isinstance(ret, Tuple) else print(ret)


if __name__ == '__main__':
    _start()
0