結果
| 問題 | No.3599 Queen Moving Query |
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2026-07-24 21:47:22 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,638 bytes |
| 記録 | |
| コンパイル時間 | 242 ms |
| コンパイル使用メモリ | 96,236 KB |
| 実行使用メモリ | 205,588 KB |
| 最終ジャッジ日時 | 2026-07-24 21:47:38 |
| 合計ジャッジ時間 | 13,955 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 WA * 8 |
ソースコード
def main():
h, w, sy, sx = list(map(int, input().split()))
sy, sx = sy-1, sx-1
inf = 1<<60
S = [input() for _ in range(h)]
D = [[[inf]*8 for _ in range(w)] for _ in range(h)]
D[sy][sx] = [1] * 8
B = [(sy, sx, i) for i in range(8)]
dy = [1, 1, 1, 0, -1, -1, -1, 0]
dx = [1, 0, -1, -1, -1, 0, 1, 1]
c = 1
while A:= B:
B = []
while A:
y, x, d = A.pop()
if D[y][x][d] < c: continue
for nd in range(8):
ny, nx = y+dy[nd], x+dx[nd]
if d == nd:
if 0 <= ny < h and 0 <= nx < w and c < D[ny][nx][nd] and S[ny][nx] == ".":
D[ny][nx][nd] = c
A.append((ny, nx, nd))
else:
if 0 <= ny < h and 0 <= nx < w and c+1 < D[ny][nx][nd] and S[ny][nx] == ".":
D[ny][nx][nd] = c+1
B.append((ny, nx, nd))
c += 1
e = sum([1 for yx in range(h*w) if max(D[yx//w][yx%w]) != -1])
if e != 2:
for _ in range(int(input())):
gy, gx, t = list(map(lambda x: int(x)-1, input().split()))
t += 1
ma = min(D[gy][gx])
if ma <= t:
print("Yes")
else:
print("No")
else:
for _ in range(int(input())):
gy, gx, t = list(map(lambda x: int(x)-1, input().split()))
t += 1
if (sy, sx) == (gy, gx):
print("Yes" if not t % 2 else "No")
elif min(D[gy][gx]) != inf:
print("Yes" if t % 2 else "No")
main()
kidodesu