結果
問題 | No.1480 Many Complete Graphs |
ユーザー |
|
提出日時 | 2021-12-28 22:07:27 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 670 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 38,564 KB |
最終ジャッジ日時 | 2024-10-02 16:17:25 |
合計ジャッジ時間 | 13,301 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 TLE * 1 -- * 35 |
ソースコード
N,M = map(int,input().split())G = [[] for _ in range(N + 1 + M)]for i in range(M):l = list(map(int,input().split()))for k in range(2,len(l)):G[l[k]].append(N + i + 1)G[N + i + 1].append((l[k],l[1]))import heapqq = []heapq.heapify(q)heapq.heappush(q,(0,1))C = 10 ** 16dist = [C] * (N + 1)dist[1] = 0import syswhile len(q):d,i = heapq.heappop(q)if i == N:print(d)exit()if d > dist[i]:continuefor m in G[i]:for s,c in G[m]:u = (i + s + 1) // 2 + c + dist[i]if u < dist[s]:dist[s] = uheapq.heappush(q,(u,s))print(-1)