結果

問題 No.1601 With Animals into Institute
ユーザー shotoyooshotoyoo
提出日時 2021-06-13 22:43:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,177 ms / 3,000 ms
コード長 841 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 168,996 KB
最終ジャッジ日時 2023-09-14 19:03:13
合計ジャッジ時間 30,840 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,072 KB
testcase_01 AC 75 ms
71,068 KB
testcase_02 AC 74 ms
71,308 KB
testcase_03 AC 158 ms
80,864 KB
testcase_04 AC 140 ms
79,076 KB
testcase_05 AC 162 ms
80,484 KB
testcase_06 AC 1,925 ms
159,900 KB
testcase_07 AC 1,942 ms
161,916 KB
testcase_08 AC 1,808 ms
160,108 KB
testcase_09 AC 1,978 ms
167,940 KB
testcase_10 AC 2,006 ms
167,728 KB
testcase_11 AC 2,023 ms
167,752 KB
testcase_12 AC 1,960 ms
168,244 KB
testcase_13 AC 2,055 ms
168,996 KB
testcase_14 AC 2,005 ms
168,244 KB
testcase_15 AC 2,000 ms
167,444 KB
testcase_16 AC 2,177 ms
168,476 KB
testcase_17 AC 2,150 ms
166,948 KB
testcase_18 AC 150 ms
80,000 KB
testcase_19 AC 143 ms
79,328 KB
testcase_20 AC 153 ms
79,984 KB
testcase_21 AC 149 ms
79,760 KB
testcase_22 AC 144 ms
79,228 KB
testcase_23 AC 150 ms
79,736 KB
testcase_24 AC 149 ms
79,704 KB
testcase_25 AC 147 ms
79,668 KB
testcase_26 AC 152 ms
80,184 KB
testcase_27 AC 75 ms
71,496 KB
testcase_28 AC 74 ms
71,528 KB
testcase_29 AC 75 ms
71,236 KB
testcase_30 AC 74 ms
71,136 KB
testcase_31 AC 74 ms
71,132 KB
testcase_32 AC 74 ms
71,384 KB
testcase_33 AC 75 ms
71,344 KB
testcase_34 AC 74 ms
71,340 KB
testcase_35 AC 75 ms
71,240 KB
testcase_36 AC 74 ms
71,384 KB
testcase_37 AC 74 ms
71,144 KB
testcase_38 AC 74 ms
71,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,m = list(map(int, input().split()))
ns = [[] for _ in range(n)]
s = 0
for i in range(m):
    a,b,c,x = map(int, input().split())
    a -= 1
    b -= 1
    ns[a].append((c,b,x))
    ns[b].append((c,a,x))
    s += c
from heapq import heappop as hpp, heappush as hp
inf = 2*s + 10
vals = [[inf]*n for _ in range(2)]
vals[0][n-1] = 0
q = [(0, n-1, 0)]
while q:
    d,u,x = hpp(q)
    if vals[x][u]<d:
        continue
    for c,v,xx in ns[u]:
        nx = x|xx
        nd = d+c
        if vals[nx][v]>nd:
            vals[nx][v] = nd
            hp(q, (nd, v, nx))
ans = vals[1]
write("\n".join(map(str, ans[:n-1])))
0