結果

問題 No.323 yuki国
ユーザー kuuso1kuuso1
提出日時 2016-06-12 04:01:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 813 ms / 5,000 ms
コード長 1,218 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 138,260 KB
最終ジャッジ日時 2023-09-10 21:34:22
合計ジャッジ時間 16,441 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,288 KB
testcase_01 AC 106 ms
77,744 KB
testcase_02 AC 99 ms
71,608 KB
testcase_03 AC 130 ms
78,476 KB
testcase_04 AC 116 ms
77,604 KB
testcase_05 AC 121 ms
78,004 KB
testcase_06 AC 114 ms
77,828 KB
testcase_07 AC 94 ms
71,432 KB
testcase_08 AC 667 ms
132,200 KB
testcase_09 AC 660 ms
132,300 KB
testcase_10 AC 92 ms
71,744 KB
testcase_11 AC 107 ms
77,812 KB
testcase_12 AC 108 ms
77,280 KB
testcase_13 AC 663 ms
137,868 KB
testcase_14 AC 667 ms
137,860 KB
testcase_15 AC 593 ms
132,508 KB
testcase_16 AC 628 ms
131,904 KB
testcase_17 AC 714 ms
137,812 KB
testcase_18 AC 267 ms
95,004 KB
testcase_19 AC 439 ms
111,880 KB
testcase_20 AC 811 ms
137,880 KB
testcase_21 AC 803 ms
138,020 KB
testcase_22 AC 813 ms
138,064 KB
testcase_23 AC 781 ms
137,936 KB
testcase_24 AC 627 ms
132,464 KB
testcase_25 AC 606 ms
127,200 KB
testcase_26 AC 712 ms
137,936 KB
testcase_27 AC 710 ms
138,080 KB
testcase_28 AC 702 ms
137,804 KB
testcase_29 AC 681 ms
138,260 KB
testcase_30 AC 95 ms
71,600 KB
testcase_31 AC 113 ms
77,836 KB
testcase_32 AC 114 ms
77,820 KB
testcase_33 AC 109 ms
77,396 KB
testcase_34 AC 118 ms
77,952 KB
testcase_35 AC 93 ms
71,712 KB
testcase_36 AC 115 ms
77,560 KB
testcase_37 AC 116 ms
77,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

h, w = map(int,input().split())
a, si, sj = map(int,input().split())
b, gi, gj = map(int,input().split())
m = [list(input()) for i in range(h)]
maxsize = 1200
visited = [[[False] * maxsize for i in range(w)] for j in range(h)]

qi = deque([h*w*maxsize])
qj = deque([h*w*maxsize])
qsize = deque([h*w*maxsize])
visited[si][sj][a] = True
qi.append(si)
qj.append(sj)
qsize.append(a)

dx = [0, 1, 0,-1]
dy = [1, 0,-1, 0]

while len(qsize):
    curi = qi.popleft()
    curj = qj.popleft()
    cursize = qsize.popleft()
    #print(cursize,curi, curj)
    for i in range(4):
        nexti = curi + dx[i]
        nextj = curj + dy[i]
        if 0 <= nexti < h and 0 <= nextj < w:
            pass
        else:
            continue

        if m[nexti][nextj] == "*":
            nextsize = cursize + 1
        else:
            nextsize = cursize - 1

        if 0 < nextsize < maxsize:
            pass
        else:
            continue

        if not visited[nexti][nextj][nextsize]:
            visited[nexti][nextj][nextsize] = True
            qi.append(nexti)
            qj.append(nextj)
            qsize.append(nextsize)

if visited[gi][gj][b]:
    print("Yes")
else:
    print("No")
0