結果
問題 | No.34 砂漠の行商人 |
ユーザー | chocorusk |
提出日時 | 2020-09-09 10:07:07 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 877 bytes |
コンパイル時間 | 863 ms |
コンパイル使用メモリ | 86,872 KB |
実行使用メモリ | 797,636 KB |
最終ジャッジ日時 | 2023-08-21 03:56:22 |
合計ジャッジ時間 | 17,391 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
71,228 KB |
testcase_01 | AC | 93 ms
71,568 KB |
testcase_02 | AC | 118 ms
77,448 KB |
testcase_03 | AC | 93 ms
71,476 KB |
testcase_04 | AC | 189 ms
103,752 KB |
testcase_05 | AC | 189 ms
103,716 KB |
testcase_06 | AC | 115 ms
78,036 KB |
testcase_07 | AC | 261 ms
111,884 KB |
testcase_08 | AC | 321 ms
122,872 KB |
testcase_09 | AC | 2,755 ms
408,028 KB |
testcase_10 | AC | 273 ms
119,840 KB |
testcase_11 | TLE | - |
testcase_12 | AC | 161 ms
92,072 KB |
testcase_13 | MLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines n, v, sx, sy, gx, gy=map(int, readline().split()) l=list(map(int, read().split())) sx-=1 sy-=1 gx-=1 gy-=1 INF=10**5 d={} d[sy*n+sx]=0 hmn=[v]*(n*n) hmn[sy*n+sx]=0 from collections import deque que=deque() que.append(sy*n+sx) while que: hxy=que.popleft() h, xy=divmod(hxy, n*n) x, y=divmod(xy, n) for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)): x1, y1=x+dx, y+dy if x1<0 or x1>=n or y1<0 or y1>=n: continue xy1=x1*n+y1 h1=l[xy1]+h if h1>=hmn[xy1]: continue hxy1=h1*n*n+xy1 if (hxy1 not in d) or d[hxy1]>d[hxy]+1: d[hxy1]=d[hxy]+1 if x1==gy and y1==gx: print(d[hxy1]) exit() que.append(hxy1) print(-1)