結果
問題 | No.1601 With Animals into Institute |
ユーザー |
|
提出日時 | 2021-06-13 22:43:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,258 ms / 3,000 ms |
コード長 | 841 bytes |
コンパイル時間 | 283 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 166,400 KB |
最終ジャッジ日時 | 2024-07-02 02:03:48 |
合計ジャッジ時間 | 30,592 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
import sysinput = 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 = 0for i in range(m):a,b,c,x = map(int, input().split())a -= 1b -= 1ns[a].append((c,b,x))ns[b].append((c,a,x))s += cfrom heapq import heappop as hpp, heappush as hpinf = 2*s + 10vals = [[inf]*n for _ in range(2)]vals[0][n-1] = 0q = [(0, n-1, 0)]while q:d,u,x = hpp(q)if vals[x][u]<d:continuefor c,v,xx in ns[u]:nx = x|xxnd = d+cif vals[nx][v]>nd:vals[nx][v] = ndhp(q, (nd, v, nx))ans = vals[1]write("\n".join(map(str, ans[:n-1])))