結果

問題 No.1601 With Animals into Institute
ユーザー 👑 rin204rin204
提出日時 2022-02-12 23:30:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,537 ms / 3,000 ms
コード長 608 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 172,916 KB
最終ジャッジ日時 2023-09-11 12:10:00
合計ジャッジ時間 38,291 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
70,932 KB
testcase_01 AC 78 ms
71,216 KB
testcase_02 AC 77 ms
70,816 KB
testcase_03 AC 251 ms
79,560 KB
testcase_04 AC 184 ms
79,584 KB
testcase_05 AC 181 ms
79,256 KB
testcase_06 AC 2,252 ms
164,172 KB
testcase_07 AC 2,537 ms
166,132 KB
testcase_08 AC 2,320 ms
165,092 KB
testcase_09 AC 2,336 ms
171,424 KB
testcase_10 AC 2,352 ms
170,576 KB
testcase_11 AC 2,274 ms
170,432 KB
testcase_12 AC 2,302 ms
170,928 KB
testcase_13 AC 2,348 ms
170,700 KB
testcase_14 AC 2,314 ms
171,420 KB
testcase_15 AC 2,312 ms
172,240 KB
testcase_16 AC 2,429 ms
172,916 KB
testcase_17 AC 2,244 ms
171,476 KB
testcase_18 AC 182 ms
80,140 KB
testcase_19 AC 168 ms
79,392 KB
testcase_20 AC 172 ms
79,644 KB
testcase_21 AC 170 ms
79,456 KB
testcase_22 AC 174 ms
79,576 KB
testcase_23 AC 172 ms
79,656 KB
testcase_24 AC 174 ms
79,920 KB
testcase_25 AC 178 ms
79,524 KB
testcase_26 AC 169 ms
79,784 KB
testcase_27 AC 76 ms
70,932 KB
testcase_28 AC 76 ms
71,100 KB
testcase_29 AC 77 ms
71,176 KB
testcase_30 AC 77 ms
70,804 KB
testcase_31 AC 77 ms
70,864 KB
testcase_32 AC 79 ms
70,980 KB
testcase_33 AC 78 ms
71,004 KB
testcase_34 AC 77 ms
71,212 KB
testcase_35 AC 78 ms
70,908 KB
testcase_36 AC 78 ms
71,028 KB
testcase_37 AC 77 ms
71,176 KB
testcase_38 AC 77 ms
70,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b, c, x = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((b, c, x))
    edges[b].append((a, c, x))

inf = 1 << 60
dist = [[inf] * 2 for _ in range(n)]
hq = [(0, n - 1, 0)]
while hq:
    d, pos, x_ = heappop(hq)
    if dist[pos][x_] < d:
        continue
    for npos, c, x in edges[pos]:
        nd = d + c
        nx = x_ | x
        if dist[npos][nx] > nd:
            dist[npos][nx] = nd
            heappush(hq, (nd, npos, nx))
for i in range(n - 1):
    print(dist[i][1])
0