結果

問題 No.3802 Crossword Key
ユーザー LyricalMaestro
提出日時 2026-11-15 03:33:38
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 59 ms / 2,000 ms
+ 468µs
コード長 968 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 89 ms
コンパイル使用メモリ 64,644 KB
実行使用メモリ 59,776 KB
最終ジャッジ日時 2026-11-15 03:33:43
合計ジャッジ時間 4,975 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# https://yukicoder.me/problems/no/3802


def main():
    H, W = map(int, input().split())
    S = []
    for _ in range(H):
        S.append(input())

    passed = [[False] * W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if S[h][w] == ".":

                new_w0 = w - 1
                new_w1 = w + 1
                if (not (0 <= new_w0 < W) or S[h][new_w0] == "#") and (0 <= new_w1 < W and S[h][new_w1] == "."):
                    passed[h][w] = True

                new_h0 = h - 1
                new_h1 = h + 1
                if (not (0 <= new_h0 < H) or S[new_h0][w] == "#") and (0 <= new_h1 < H and S[new_h1][w] == "."):
                    passed[h][w] = True


    answers = []
    for h in range(H):
        for w in range(W):
            if passed[h][w]:
                answers.append((h + 1, w + 1))

    print(len(answers))
    for h, w in answers:
        print(h, w)






if __name__ == "__main__":
    main()
0