結果
問題 | No.1283 Extra Fee |
ユーザー | 👑 platinum |
提出日時 | 2020-09-05 01:04:07 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,216 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 49,152 KB |
最終ジャッジ日時 | 2024-05-05 04:03:48 |
合計ジャッジ時間 | 7,956 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
16,384 KB |
testcase_01 | AC | 30 ms
10,880 KB |
testcase_02 | AC | 27 ms
11,008 KB |
testcase_03 | AC | 28 ms
10,880 KB |
testcase_04 | AC | 28 ms
11,008 KB |
testcase_05 | AC | 27 ms
10,880 KB |
testcase_06 | AC | 29 ms
10,880 KB |
testcase_07 | AC | 28 ms
10,880 KB |
testcase_08 | AC | 28 ms
10,880 KB |
testcase_09 | AC | 28 ms
10,880 KB |
testcase_10 | AC | 27 ms
11,008 KB |
testcase_11 | AC | 170 ms
12,160 KB |
testcase_12 | AC | 209 ms
12,544 KB |
testcase_13 | AC | 146 ms
12,160 KB |
testcase_14 | AC | 566 ms
16,384 KB |
testcase_15 | AC | 900 ms
19,328 KB |
testcase_16 | AC | 210 ms
12,672 KB |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
ソースコード
from heapq import heappush,heappop INF = int(1e15) dh = [1,0,-1,0] dw = [0,1,0,-1] N, M = map(int,input().split()) dist0 = [[INF for j in range(N)] for i in range(N)] dist1 = [[INF for j in range(N)] for i in range(N)] c = [[0 for j in range(N)] for i in range(N)] dist0[0][0] = 0 dist1[0][0] = 0 for i in range(M): H, W, C = map(int,input().split()) H -= 1 W -= 1 c[H][W] = C q = [(0,0,0,0)] while q: C, H, W, used = heappop(q) if(used == 0 and dist0[H][W] < C): continue if(used == 1 and dist1[H][W] < C): continue for i in range(4): nH = H + dh[i] nW = W + dw[i] if(nH < 0 or nH >= N): continue if(nW < 0 or nW >= N): continue nC0 = C + c[nH][nW] + 1 nC1 = C + 1 if(used == 0): if(dist0[nH][nW] > nC0): heappush(q,(nC0,nH,nW,0)) dist0[nH][nW] = nC0 if(dist1[nH][nW] > nC1): heappush(q,(nC1,nH,nW,1)) dist1[nH][nW] = nC1 else: if(dist1[nH][nW] > nC0): heappush(q,(nC0,nH,nW,1)) dist1[nH][nW] = nC0 print(min(dist0[N-1][N-1],dist1[N-1][N-1]))