結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2022-01-05 10:27:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,063 bytes |
コンパイル時間 | 1,519 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 109,824 KB |
最終ジャッジ日時 | 2024-10-15 14:42:34 |
合計ジャッジ時間 | 13,871 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 30 WA * 2 |
ソースコード
import sysimport io, osinput = sys.stdin.readlinedef main():h, w = map(int, input().split())a, si, sj = map(int, input().split())b, ti, tj = map(int, input().split())M = [str(input().rstrip()) for i in range(h)]visit = [[False]*1051 for i in range(h*w)]from collections import dequeq = deque([])s = si*w+sjt = ti*w+tjq.append((s, a))visit[s][a] = Truewhile q:v, x = q.popleft()if v == t and x == b:breaki, j = divmod(v, w)for di, dj in (-1, 0), (1, 0), (0, 1), (0, -1):ni, nj = i+di, j+djif 0 <= ni < h and 0 <= nj < w:nv = ni*w+njif M[ni][nj] == '*':nx = x+1else:nx = x-1if nx >= 1 and nx <= 1050 and not visit[nv][nx]:q.append((nv, nx))visit[nv][nx] = Trueif visit[t][b]:print('Yes')else:print('No')if __name__ == '__main__':main()