結果

問題 No.1601 With Animals into Institute
ユーザー shotoyooshotoyoo
提出日時 2021-06-24 22:30:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,510 ms / 3,000 ms
コード長 841 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 84,056 KB
最終ジャッジ日時 2023-09-14 19:06:45
合計ジャッジ時間 33,271 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,332 KB
testcase_01 AC 17 ms
8,192 KB
testcase_02 AC 16 ms
8,168 KB
testcase_03 AC 44 ms
9,464 KB
testcase_04 AC 44 ms
9,372 KB
testcase_05 AC 42 ms
9,516 KB
testcase_06 AC 2,318 ms
83,540 KB
testcase_07 AC 2,370 ms
83,548 KB
testcase_08 AC 2,440 ms
83,956 KB
testcase_09 AC 2,432 ms
83,564 KB
testcase_10 AC 2,442 ms
83,628 KB
testcase_11 AC 2,510 ms
84,056 KB
testcase_12 AC 2,357 ms
83,652 KB
testcase_13 AC 2,387 ms
83,464 KB
testcase_14 AC 2,429 ms
83,632 KB
testcase_15 AC 2,375 ms
83,632 KB
testcase_16 AC 2,432 ms
83,588 KB
testcase_17 AC 2,487 ms
83,748 KB
testcase_18 AC 45 ms
9,692 KB
testcase_19 AC 45 ms
9,692 KB
testcase_20 AC 44 ms
9,688 KB
testcase_21 AC 43 ms
9,656 KB
testcase_22 AC 44 ms
9,648 KB
testcase_23 AC 43 ms
9,688 KB
testcase_24 AC 44 ms
9,780 KB
testcase_25 AC 46 ms
9,748 KB
testcase_26 AC 44 ms
9,780 KB
testcase_27 AC 16 ms
8,316 KB
testcase_28 AC 16 ms
8,276 KB
testcase_29 AC 16 ms
8,260 KB
testcase_30 AC 17 ms
8,180 KB
testcase_31 AC 16 ms
8,164 KB
testcase_32 AC 16 ms
8,184 KB
testcase_33 AC 17 ms
8,216 KB
testcase_34 AC 17 ms
8,320 KB
testcase_35 AC 16 ms
8,240 KB
testcase_36 AC 17 ms
8,196 KB
testcase_37 AC 17 ms
8,272 KB
testcase_38 AC 17 ms
8,280 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