結果
問題 | No.1301 Strange Graph Shortest Path |
ユーザー | Shinya Fujita |
提出日時 | 2024-10-27 00:50:10 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,240 bytes |
コンパイル時間 | 400 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 281,508 KB |
最終ジャッジ日時 | 2024-10-27 00:51:49 |
合計ジャッジ時間 | 95,000 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
52,956 KB |
testcase_01 | AC | 37 ms
53,104 KB |
testcase_02 | TLE | - |
testcase_03 | AC | 2,652 ms
253,908 KB |
testcase_04 | AC | 2,860 ms
281,508 KB |
testcase_05 | TLE | - |
testcase_06 | AC | 2,745 ms
275,080 KB |
testcase_07 | AC | 2,930 ms
275,032 KB |
testcase_08 | AC | 2,630 ms
253,784 KB |
testcase_09 | AC | 2,510 ms
269,884 KB |
testcase_10 | WA | - |
testcase_11 | AC | 2,990 ms
275,704 KB |
testcase_12 | AC | 2,888 ms
276,424 KB |
testcase_13 | TLE | - |
testcase_14 | AC | 2,632 ms
269,272 KB |
testcase_15 | AC | 2,762 ms
272,368 KB |
testcase_16 | AC | 2,872 ms
277,560 KB |
testcase_17 | TLE | - |
testcase_18 | AC | 2,941 ms
272,668 KB |
testcase_19 | AC | 2,751 ms
275,096 KB |
testcase_20 | AC | 2,553 ms
276,296 KB |
testcase_21 | TLE | - |
testcase_22 | AC | 2,480 ms
277,016 KB |
testcase_23 | TLE | - |
testcase_24 | AC | 2,647 ms
275,824 KB |
testcase_25 | TLE | - |
testcase_26 | AC | 2,898 ms
276,804 KB |
testcase_27 | AC | 2,930 ms
275,004 KB |
testcase_28 | TLE | - |
testcase_29 | WA | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | TLE | - |
ソースコード
from heapq import heappop, heappush N, M = map(int, input().split()) graph = [[] for _ in range(N)] pos = {} for _ in range(M): a, b, c, d = map(int, input().split()) a -= 1; b -= 1 pos[a, b, c] = len(graph[a]) pos[b, a, c] = len(graph[b]) graph[a].append([b, c]) graph[b].append([a, c]) pos[a, b, d] = len(graph[a]) pos[b, a, d] = len(graph[b]) graph[a].append([b, d]) graph[b].append([a, d]) D = [[-1, None, None] for _ in range(N)] hq = [(0, 0, None, None)] while hq: d, node, par, c = heappop(hq) if D[node][0] != -1: continue D[node] = [d, par, c] for nex, c in graph[node]: if D[nex][0] == -1: heappush(hq, (D[node][0]+c, nex, node, c)) INF = 10**10 ans = D[N-1][0] now = N-1 while now: _, par, c = D[now] i1 = pos[par, now, c] i2 = pos[now, par, c] graph[par][i1][1] = graph[now][i2][1] = INF now = par D = [[-1, None, None] for _ in range(N)] hq = [(0, N-1, None, None)] while hq: d, node, par, c = heappop(hq) if D[node][0] != -1: continue D[node] = [d, par, c] for nex, c in graph[node]: if D[nex][0] == -1: heappush(hq, (D[node][0]+c, nex, node, c)) print(D[0][0]+ans)