結果

問題 No.323 yuki国
ユーザー rlangevinrlangevin
提出日時 2023-09-29 12:07:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,392 ms / 5,000 ms
コード長 826 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 387,616 KB
最終ジャッジ日時 2023-09-29 12:08:03
合計ジャッジ時間 33,704 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,660 KB
testcase_01 AC 88 ms
71,472 KB
testcase_02 AC 90 ms
71,252 KB
testcase_03 AC 97 ms
76,200 KB
testcase_04 AC 89 ms
71,656 KB
testcase_05 AC 124 ms
78,720 KB
testcase_06 AC 114 ms
77,960 KB
testcase_07 AC 90 ms
71,500 KB
testcase_08 AC 2,369 ms
387,128 KB
testcase_09 AC 2,220 ms
338,644 KB
testcase_10 AC 88 ms
71,532 KB
testcase_11 AC 117 ms
77,956 KB
testcase_12 AC 109 ms
77,780 KB
testcase_13 AC 1,771 ms
331,428 KB
testcase_14 AC 2,153 ms
387,616 KB
testcase_15 AC 1,481 ms
292,912 KB
testcase_16 AC 2,155 ms
387,304 KB
testcase_17 AC 1,846 ms
324,204 KB
testcase_18 AC 140 ms
78,580 KB
testcase_19 AC 1,372 ms
292,392 KB
testcase_20 AC 148 ms
83,000 KB
testcase_21 AC 2,377 ms
337,532 KB
testcase_22 AC 549 ms
154,572 KB
testcase_23 AC 2,392 ms
337,244 KB
testcase_24 AC 236 ms
95,792 KB
testcase_25 AC 1,725 ms
324,560 KB
testcase_26 AC 235 ms
95,832 KB
testcase_27 AC 2,151 ms
387,616 KB
testcase_28 AC 1,912 ms
331,000 KB
testcase_29 AC 2,122 ms
335,260 KB
testcase_30 AC 90 ms
71,440 KB
testcase_31 AC 114 ms
77,880 KB
testcase_32 AC 119 ms
77,640 KB
testcase_33 AC 109 ms
77,688 KB
testcase_34 AC 147 ms
77,980 KB
testcase_35 AC 92 ms
71,744 KB
testcase_36 AC 120 ms
77,704 KB
testcase_37 AC 89 ms
71,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

H, W = map(int, input().split())
A, sx, sy = map(int, input().split())
B, gx, gy = map(int, input().split())
G = []
for i in range(H):
    G.append(list(input()))

Q = deque()
Q.append((sx, sy, A))
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
M = 1200
S = set()
S.add((sx, sy, A))
while Q:
    px, py, c = Q.popleft()
    for k in range(4):
        x = px + dx[k]
        y = py + dy[k]
        if x < 0 or x > H - 1 or y < 0 or y > W - 1:
            continue
        if G[x][y] == "*":
            nc = c + 1  
        else:
            nc = c - 1
        if nc <= 0 or nc >= M:
            continue
        if (x, y, nc) in S:
            continue
        S.add((x, y, nc))
        Q.append((x, y, nc))
        if B == nc and x == gx and y == gy:
            print("Yes")
            exit()

print("No")
0