結果
問題 |
No.1545 [Cherry 2nd Tune N] Anthem
|
ユーザー |
👑 ![]() |
提出日時 | 2021-04-06 03:07:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,409 bytes |
コンパイル時間 | 380 ms |
コンパイル使用メモリ | 82,508 KB |
実行使用メモリ | 156,236 KB |
最終ジャッジ日時 | 2024-12-14 19:37:09 |
合計ジャッジ時間 | 25,065 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 66 TLE * 1 |
ソースコード
#TLE想定 continue 忘れ class Heap_Point: def __init__(self,x,d): self.d=d self.x=x def __str__(self): return "(point:{}, dist:{})".format(self.x,self.d) def __repr__(self): return str(self) def __lt__(self,other): return self.d<other.d def __iter__(self): yield from (self.x,self.d) #================================================ import sys from heapq import heapify,heappop,heappush input=sys.stdin.readline N,S,T,K=map(int,input().split()) X=["*"]+list(map(int,input().split())) M=int(input()) E=[[] for _ in range(N+1)] for _ in range(M): A,B,Y=map(int,input().split()) E[A].append((B,Y)) inf=float("inf") DP=[[inf]*(K+1) for _ in range(N+1)] DP[S][1]=X[S] Reverse=[[(0,0) for _ in range(K+1)] for _ in range(N+1)] Q=[Heap_Point((S,1),0)] heapify(Q) while Q: (x,k),d=heappop(Q) """if DP[x][k]<d: continue""" if x==T and k==K: break l=min(k+1,K) for y,m in E[x]: if DP[x][k]+m+X[y]<DP[y][l]: DP[y][l]=DP[x][k]+m+X[y] Reverse[y][l]=(x,k) heappush(Q,Heap_Point((y,l),DP[y][l])) V=DP[T][K] if V<inf: x,k=T,K P=[] while k>0: P.append(x) x,k=Reverse[x][k] print("Possible") print(V) print(len(P)) print(*P[::-1]) else: print("Impossible")