結果
問題 | No.1545 [Cherry 2nd Tune N] Anthem |
ユーザー | ygd. |
提出日時 | 2021-06-15 23:02:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,037 bytes |
コンパイル時間 | 335 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 199,136 KB |
最終ジャッジ日時 | 2024-06-08 15:31:11 |
合計ジャッジ時間 | 48,166 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,608 KB |
testcase_01 | AC | 35 ms
52,864 KB |
testcase_02 | AC | 38 ms
52,992 KB |
testcase_03 | AC | 43 ms
53,760 KB |
testcase_04 | AC | 159 ms
94,952 KB |
testcase_05 | AC | 2,103 ms
156,264 KB |
testcase_06 | WA | - |
testcase_07 | AC | 189 ms
102,328 KB |
testcase_08 | AC | 1,857 ms
125,328 KB |
testcase_09 | AC | 842 ms
100,616 KB |
testcase_10 | AC | 191 ms
109,156 KB |
testcase_11 | AC | 493 ms
110,616 KB |
testcase_12 | AC | 898 ms
132,040 KB |
testcase_13 | AC | 255 ms
95,872 KB |
testcase_14 | AC | 132 ms
84,224 KB |
testcase_15 | WA | - |
testcase_16 | AC | 166 ms
89,376 KB |
testcase_17 | AC | 432 ms
88,428 KB |
testcase_18 | AC | 368 ms
132,168 KB |
testcase_19 | AC | 774 ms
116,056 KB |
testcase_20 | AC | 437 ms
88,244 KB |
testcase_21 | AC | 211 ms
110,296 KB |
testcase_22 | AC | 229 ms
124,660 KB |
testcase_23 | AC | 1,949 ms
128,900 KB |
testcase_24 | AC | 983 ms
88,360 KB |
testcase_25 | AC | 318 ms
79,480 KB |
testcase_26 | AC | 151 ms
78,108 KB |
testcase_27 | AC | 259 ms
79,532 KB |
testcase_28 | AC | 500 ms
83,204 KB |
testcase_29 | AC | 777 ms
88,176 KB |
testcase_30 | AC | 431 ms
81,136 KB |
testcase_31 | AC | 463 ms
82,268 KB |
testcase_32 | AC | 193 ms
77,568 KB |
testcase_33 | AC | 637 ms
84,308 KB |
testcase_34 | AC | 447 ms
82,372 KB |
testcase_35 | AC | 836 ms
86,676 KB |
testcase_36 | AC | 720 ms
84,676 KB |
testcase_37 | AC | 211 ms
78,080 KB |
testcase_38 | AC | 367 ms
79,860 KB |
testcase_39 | AC | 198 ms
77,908 KB |
testcase_40 | AC | 384 ms
80,448 KB |
testcase_41 | AC | 167 ms
77,644 KB |
testcase_42 | AC | 576 ms
86,716 KB |
testcase_43 | AC | 586 ms
85,656 KB |
testcase_44 | AC | 80 ms
80,896 KB |
testcase_45 | AC | 53 ms
73,088 KB |
testcase_46 | AC | 641 ms
92,956 KB |
testcase_47 | AC | 483 ms
92,804 KB |
testcase_48 | AC | 393 ms
98,676 KB |
testcase_49 | AC | 819 ms
96,872 KB |
testcase_50 | AC | 991 ms
104,404 KB |
testcase_51 | AC | 1,417 ms
108,292 KB |
testcase_52 | AC | 1,023 ms
105,692 KB |
testcase_53 | AC | 488 ms
93,868 KB |
testcase_54 | AC | 711 ms
102,076 KB |
testcase_55 | AC | 904 ms
100,916 KB |
testcase_56 | AC | 77 ms
80,640 KB |
testcase_57 | AC | 1,354 ms
108,896 KB |
testcase_58 | AC | 570 ms
93,812 KB |
testcase_59 | AC | 634 ms
95,972 KB |
testcase_60 | AC | 126 ms
87,296 KB |
testcase_61 | AC | 992 ms
96,156 KB |
testcase_62 | AC | 1,136 ms
102,764 KB |
testcase_63 | AC | 1,171 ms
102,732 KB |
testcase_64 | AC | 2,161 ms
199,136 KB |
testcase_65 | AC | 422 ms
89,572 KB |
testcase_66 | WA | - |
ソースコード
from heapq import heapify, heappop, heappush from math import inf def main(): N,S,T,K = map(int,input().split()); INF = float("inf") S-=1;T-=1 #0-index X = list(map(int,input().split())) G = [[] for _ in range(N)] M = int(input()) for _ in range(M): A,B,Y = map(int,input().split()) A-=1;B-=1 G[A].append((Y,B)) def dijkstra_heap2(s,G,K): INF = float("inf") #S:start, V: node, E: Edge, G: Graph V = len(G) #dp[i][j]: i番目の歌を歌って今j曲目(i番目の歌を含む) if K <= 10: MAX = 15 elif K <= 130: MAX = 1000 else: MAX = pow(10,5) dp = [[INF]*MAX for _ in range(V)] #d = [INF for _ in range(V)] dp[s][1] = X[s] prev = [[-1]*MAX for _ in range(V)] PQ = [] heappush(PQ,(X[s],s,1)) #時間, 位置, 何曲目 while PQ: c,v,n = heappop(PQ) if dp[v][n] < c: continue dp[v][n] = c if n+1 >= MAX: #これ以上は配列外参照 continue for cost,u in G[v]: if dp[u][n+1] <= cost + X[u] + dp[v][n]: continue dp[u][n+1] = cost + X[u] + dp[v][n] prev[u][n+1] = v heappush(PQ,(dp[u][n+1], u, n+1)) return dp, prev d, keiro = dijkstra_heap2(S,G,K) #print(d) #print(keiro) ans = INF num = INF #何曲か for i in range(K,len(d[T])): if d[T][i] < ans: ans = d[T][i] num = i if ans == INF: print("Impossible") else: print("Possible") print(ans) print(num) ret = [T+1] #1-index #num -= 1 now = T while num > 1: pre = keiro[now][num] ret.append(pre+1) #1-index now = pre num -= 1 ret.reverse() print(*ret) if __name__ == '__main__': main()