結果

問題 No.1301 Strange Graph Shortest Path
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2020-11-27 22:56:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 113,792 KB
最終ジャッジ日時 2023-10-09 21:52:18
合計ジャッジ時間 23,633 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,700 KB
testcase_01 AC 95 ms
71,572 KB
testcase_02 WA -
testcase_03 AC 559 ms
101,112 KB
testcase_04 AC 613 ms
109,528 KB
testcase_05 AC 691 ms
101,756 KB
testcase_06 AC 604 ms
106,256 KB
testcase_07 AC 581 ms
103,456 KB
testcase_08 AC 530 ms
99,172 KB
testcase_09 AC 597 ms
107,408 KB
testcase_10 WA -
testcase_11 AC 589 ms
105,664 KB
testcase_12 AC 635 ms
107,060 KB
testcase_13 AC 761 ms
103,936 KB
testcase_14 AC 591 ms
106,472 KB
testcase_15 AC 625 ms
103,708 KB
testcase_16 AC 660 ms
112,996 KB
testcase_17 AC 674 ms
106,972 KB
testcase_18 AC 631 ms
102,276 KB
testcase_19 AC 587 ms
106,932 KB
testcase_20 AC 585 ms
109,836 KB
testcase_21 AC 654 ms
105,320 KB
testcase_22 AC 541 ms
108,896 KB
testcase_23 AC 704 ms
104,600 KB
testcase_24 AC 599 ms
107,488 KB
testcase_25 AC 607 ms
111,208 KB
testcase_26 AC 629 ms
104,104 KB
testcase_27 AC 657 ms
106,268 KB
testcase_28 AC 683 ms
101,116 KB
testcase_29 WA -
testcase_30 AC 657 ms
111,244 KB
testcase_31 AC 666 ms
111,740 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 543 ms
105,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n,m = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
    u,v,c,d = map(int,input().split())
    e[u].append([v,c,d])
    e[v].append([u,c,d])
dis = [10**20]*(n+1)
dis[1] = 0
par = [-1]*(n+1)
q = deque([1])
while q:
    now = q.popleft()
    for nex,c,d in e[now]:
        if dis[nex] > dis[now]+c:
            dis[nex] = dis[now]+c
            par[nex] = now
            q.append(nex)
ans = dis[n]
now = n
while par[now] != -1:
    p = par[now]
    for i in range(len(e[now])):
        if e[now][i][0] == p:
            e[now][i][1] = -1
            break
    now = p
dis = [10**20]*(n+1)
dis[n] = 0
q = deque([n])
while q:
    now = q.popleft()
    for nex,c,d in e[now]:
        if c == -1:
            if dis[nex] > dis[now]+d:
                dis[nex] = dis[now]+d
                q.append(nex)
        else:
            if dis[nex] > dis[now]+c:
                dis[nex] = dis[now]+c
                q.append(nex)
ans += dis[1]
print(ans)
0