結果

問題 No.1601 With Animals into Institute
ユーザー ああいいああいい
提出日時 2022-01-10 21:44:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,245 ms / 3,000 ms
コード長 976 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 82,152 KB
実行使用メモリ 160,460 KB
最終ジャッジ日時 2024-04-26 20:23:28
合計ジャッジ時間 30,821 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
54,496 KB
testcase_01 AC 38 ms
53,080 KB
testcase_02 AC 38 ms
53,840 KB
testcase_03 AC 151 ms
78,796 KB
testcase_04 AC 150 ms
78,720 KB
testcase_05 AC 150 ms
79,232 KB
testcase_06 AC 1,953 ms
158,480 KB
testcase_07 AC 2,058 ms
160,460 KB
testcase_08 AC 2,036 ms
159,132 KB
testcase_09 AC 2,144 ms
159,128 KB
testcase_10 AC 2,053 ms
158,456 KB
testcase_11 AC 2,164 ms
160,284 KB
testcase_12 AC 2,084 ms
158,612 KB
testcase_13 AC 2,230 ms
159,536 KB
testcase_14 AC 2,245 ms
159,844 KB
testcase_15 AC 2,205 ms
159,256 KB
testcase_16 AC 2,159 ms
158,824 KB
testcase_17 AC 2,146 ms
159,340 KB
testcase_18 AC 153 ms
78,836 KB
testcase_19 AC 154 ms
79,104 KB
testcase_20 AC 152 ms
79,220 KB
testcase_21 AC 154 ms
78,704 KB
testcase_22 AC 151 ms
78,976 KB
testcase_23 AC 151 ms
79,276 KB
testcase_24 AC 160 ms
78,592 KB
testcase_25 AC 158 ms
79,100 KB
testcase_26 AC 160 ms
78,720 KB
testcase_27 AC 39 ms
52,608 KB
testcase_28 AC 38 ms
52,736 KB
testcase_29 AC 40 ms
52,608 KB
testcase_30 AC 40 ms
52,992 KB
testcase_31 AC 41 ms
53,248 KB
testcase_32 AC 39 ms
52,864 KB
testcase_33 AC 42 ms
53,120 KB
testcase_34 AC 41 ms
52,608 KB
testcase_35 AC 42 ms
53,248 KB
testcase_36 AC 42 ms
52,608 KB
testcase_37 AC 41 ms
52,864 KB
testcase_38 AC 40 ms
52,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

G = [[] for _ in range(N+1)]
for _ in range(M):
    a,b,c,x = map(int,input().split())
    G[a].append((b,c,x>0))
    G[b].append((a,c,x>0))
import heapq
q = []
heapq.heapify(q)
C = 10 ** 18
dist = [[C] * 2 for _ in range(N+1)]
dist[N][0] = 0
heapq.heappush(q,(0,N,False))
while q:
    d,now,flag = heapq.heappop(q)
    if flag:
        if d > dist[now][1]:continue
        for v,c,x in G[now]:
            if dist[v][1] > d + c:
                dist[v][1] = d + c
                heapq.heappush(q,(d+c,v,True))
    else:
        if d > dist[now][0] or d > dist[now][1]:continue
        for v,c,x in G[now]:
            if x:
                if dist[v][1] > d + c:
                    dist[v][1] = d+c
                    heapq.heappush(q,(d+c,v,True))
            else:
                if dist[v][0] > d + c:
                    dist[v][0] = d + c
                    heapq.heappush(q,(d+c,v,False))
for i in range(1,N):
    print(dist[i][1])
0