結果

問題 No.2366 登校
ユーザー titiatitia
提出日時 2023-07-01 02:16:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 904 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 160,748 KB
最終ジャッジ日時 2023-09-22 05:25:59
合計ジャッジ時間 35,509 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
77,420 KB
testcase_01 AC 78 ms
71,224 KB
testcase_02 AC 96 ms
76,352 KB
testcase_03 AC 184 ms
80,160 KB
testcase_04 AC 77 ms
71,456 KB
testcase_05 AC 104 ms
77,128 KB
testcase_06 AC 162 ms
79,152 KB
testcase_07 AC 188 ms
78,940 KB
testcase_08 AC 221 ms
80,192 KB
testcase_09 AC 191 ms
79,464 KB
testcase_10 AC 99 ms
76,492 KB
testcase_11 AC 133 ms
77,912 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2,680 ms
116,956 KB
testcase_16 AC 2,662 ms
118,444 KB
testcase_17 AC 2,609 ms
117,048 KB
testcase_18 WA -
testcase_19 AC 2,584 ms
118,896 KB
testcase_20 AC 2,631 ms
118,524 KB
testcase_21 AC 2,603 ms
117,876 KB
testcase_22 AC 1,145 ms
101,756 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import heappop,heappush

N,M,K,T=map(int,input().split())

X=[[(-1,-1)]*M for i in range(N)]

for i in range(K):
    a,b,c,d=map(int,input().split())
    a-=1
    b-=1
    X[a][b]=[c,d]

DP=[[[1<<63]*M for i in range(N)] for j in range(400)]

Q=[(0,0,0,0)]
DP[200][0][0]=0

while Q:
    #print(Q)
    now,x,y,time=heappop(Q)

    for z,w in [(x,y+1),(x,y-1),(x+1,y),(x-1,y)]:
        if 0<=z<N and 0<=w<M and 0<=time+1+200<400 and DP[time+1+200][z][w]>now:
            DP[time+1+200][z][w]=now
            heappush(Q,(DP[time+1+200][z][w],z,w,time+1))

    if X[x][y]!=(-1,-1):
        c,d=X[x][y]
        if 0<=time-c+200<400 and DP[time-c+200][z][w]>now+d:
            DP[time-c+200][z][w]=now+d
            heappush(Q,(DP[time-c+200][z][w],x,y,time-c))

ANS=1<<63

for i in range(400):
    if i-200<=T:
        ANS=min(ANS,DP[i][N-1][M-1])

print(ANS)
0