結果

問題 No.1601 With Animals into Institute
ユーザー roarisroaris
提出日時 2021-07-13 01:22:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,309 ms / 3,000 ms
コード長 803 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 86,712 KB
実行使用メモリ 144,128 KB
最終ジャッジ日時 2023-09-14 21:39:24
合計ジャッジ時間 22,589 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,028 KB
testcase_01 AC 74 ms
71,220 KB
testcase_02 AC 74 ms
70,856 KB
testcase_03 AC 148 ms
79,304 KB
testcase_04 AC 149 ms
79,356 KB
testcase_05 AC 156 ms
79,516 KB
testcase_06 AC 1,146 ms
138,524 KB
testcase_07 AC 1,221 ms
139,100 KB
testcase_08 AC 1,160 ms
137,816 KB
testcase_09 AC 1,213 ms
143,416 KB
testcase_10 AC 1,169 ms
143,852 KB
testcase_11 AC 1,213 ms
143,852 KB
testcase_12 AC 1,203 ms
143,588 KB
testcase_13 AC 1,281 ms
144,080 KB
testcase_14 AC 1,216 ms
143,704 KB
testcase_15 AC 1,297 ms
143,884 KB
testcase_16 AC 1,309 ms
144,128 KB
testcase_17 AC 1,233 ms
143,988 KB
testcase_18 AC 153 ms
79,360 KB
testcase_19 AC 148 ms
79,144 KB
testcase_20 AC 155 ms
79,192 KB
testcase_21 AC 152 ms
79,188 KB
testcase_22 AC 148 ms
79,148 KB
testcase_23 AC 146 ms
79,552 KB
testcase_24 AC 150 ms
79,340 KB
testcase_25 AC 150 ms
79,856 KB
testcase_26 AC 151 ms
79,188 KB
testcase_27 AC 75 ms
71,192 KB
testcase_28 AC 75 ms
71,140 KB
testcase_29 AC 75 ms
71,100 KB
testcase_30 AC 74 ms
71,324 KB
testcase_31 AC 75 ms
71,144 KB
testcase_32 AC 76 ms
71,344 KB
testcase_33 AC 76 ms
71,252 KB
testcase_34 AC 76 ms
71,376 KB
testcase_35 AC 76 ms
71,328 KB
testcase_36 AC 74 ms
71,400 KB
testcase_37 AC 76 ms
70,944 KB
testcase_38 AC 75 ms
71,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *

def dijkstra():
    dist = [[10**18]*N for _ in range(2)]
    dist[0][N-1] = 0
    pq = []
    heappush(pq, (0, N-1))
    
    while pq:
        d, tv = heappop(pq)
        t, v = divmod(tv, 10**6)
        
        if dist[t][v]<d:
            continue
        
        for nv, w, x in G[v]:
            nt = t|(x==1)
            
            if dist[nt][nv]>dist[t][v]+w:
                dist[nt][nv] = dist[t][v]+w
                heappush(pq, (dist[nt][nv], 10**6*nt+nv))
    
    return dist

N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
    A, B, C, X = map(int, input().split())
    G[A-1].append((B-1, C, X))
    G[B-1].append((A-1, C, X))

dist = dijkstra()

for i in range(N-1):
    print(dist[1][i])
0