結果

問題 No.3599 Queen Moving Query
コンテスト
ユーザー gomaazarasi
提出日時 2026-07-01 16:46:56
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 998 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 235 ms
コンパイル使用メモリ 96,104 KB
実行使用メモリ 189,312 KB
最終ジャッジ日時 2026-07-24 20:34:36
合計ジャッジ時間 18,212 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque

move = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]

h,w,sy,sx = list(map(int,input().split()))
a = [list(input()) for i in range(h)]
s = [[[[0,0] for i in range(8)] for u in range(w)] for j in range(h)]
sy,sx = sy-1,sx-1

d = deque([(sy,sx,0,-1)])

while len(d):
    y,x,z,c = d.popleft()
    
    for i in range(8):
        Y,X = move[i]
        if 0 <= y+Y < h and 0 <= x+X < w and a[y+Y][x+X] == '.' and s[y+Y][x+X][i][z^1] == 0:
            s[y+Y][x+X][i][z^1] = s[y][x][c][z]+1
            d.append((y+Y,x+X,z^1,i))
        
        if 0 <= y+Y < h and 0 <= x+X < w and a[y+Y][x+X] == '.' and s[y+Y][x+X][i][z] == 0 and c == i:
            s[y+Y][x+X][c][z] = s[y][x][c][z]
            d.append((y+Y,x+X,z,i))

q = int(input())

for _ in range(q):
    y,x,t = list(map(int,input().split()))
    y,x = y-1,x-1
    ans = "No"
    
    for i in range(8):
        if 0 < s[y][x][i][t%2] <= t:
            ans = "Yes"
            break
    
    print(ans)
0