結果
問題 | No.1545 [Cherry 2nd Tune N] Anthem |
ユーザー | qib |
提出日時 | 2022-11-09 21:50:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,227 ms / 3,000 ms |
コード長 | 1,276 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 451,348 KB |
最終ジャッジ日時 | 2024-07-23 02:57:23 |
合計ジャッジ時間 | 39,034 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,440 KB |
testcase_01 | AC | 37 ms
54,284 KB |
testcase_02 | AC | 37 ms
53,168 KB |
testcase_03 | AC | 37 ms
53,692 KB |
testcase_04 | AC | 495 ms
198,948 KB |
testcase_05 | AC | 2,227 ms
421,372 KB |
testcase_06 | AC | 691 ms
201,796 KB |
testcase_07 | AC | 544 ms
176,784 KB |
testcase_08 | AC | 1,642 ms
327,972 KB |
testcase_09 | AC | 465 ms
143,972 KB |
testcase_10 | AC | 195 ms
94,516 KB |
testcase_11 | AC | 880 ms
258,104 KB |
testcase_12 | AC | 1,826 ms
354,004 KB |
testcase_13 | AC | 409 ms
139,584 KB |
testcase_14 | AC | 584 ms
216,132 KB |
testcase_15 | AC | 161 ms
89,084 KB |
testcase_16 | AC | 930 ms
285,924 KB |
testcase_17 | AC | 205 ms
88,556 KB |
testcase_18 | AC | 529 ms
128,276 KB |
testcase_19 | AC | 718 ms
197,972 KB |
testcase_20 | AC | 433 ms
148,820 KB |
testcase_21 | AC | 1,034 ms
336,272 KB |
testcase_22 | AC | 483 ms
182,076 KB |
testcase_23 | AC | 525 ms
135,664 KB |
testcase_24 | AC | 157 ms
95,468 KB |
testcase_25 | AC | 215 ms
108,888 KB |
testcase_26 | AC | 64 ms
68,452 KB |
testcase_27 | AC | 155 ms
89,248 KB |
testcase_28 | AC | 246 ms
117,516 KB |
testcase_29 | AC | 209 ms
109,728 KB |
testcase_30 | AC | 193 ms
109,000 KB |
testcase_31 | AC | 228 ms
108,792 KB |
testcase_32 | AC | 178 ms
89,400 KB |
testcase_33 | AC | 257 ms
116,816 KB |
testcase_34 | AC | 236 ms
111,280 KB |
testcase_35 | AC | 473 ms
191,468 KB |
testcase_36 | AC | 391 ms
162,428 KB |
testcase_37 | AC | 116 ms
82,588 KB |
testcase_38 | AC | 254 ms
121,088 KB |
testcase_39 | AC | 154 ms
84,852 KB |
testcase_40 | AC | 150 ms
94,620 KB |
testcase_41 | AC | 117 ms
80,644 KB |
testcase_42 | AC | 209 ms
106,608 KB |
testcase_43 | AC | 226 ms
111,516 KB |
testcase_44 | AC | 77 ms
80,792 KB |
testcase_45 | AC | 54 ms
70,960 KB |
testcase_46 | AC | 201 ms
105,456 KB |
testcase_47 | AC | 254 ms
125,952 KB |
testcase_48 | AC | 379 ms
159,820 KB |
testcase_49 | AC | 421 ms
169,956 KB |
testcase_50 | AC | 637 ms
235,376 KB |
testcase_51 | AC | 129 ms
85,376 KB |
testcase_52 | AC | 1,062 ms
356,112 KB |
testcase_53 | AC | 335 ms
149,536 KB |
testcase_54 | AC | 135 ms
89,816 KB |
testcase_55 | AC | 605 ms
251,132 KB |
testcase_56 | AC | 78 ms
81,280 KB |
testcase_57 | AC | 552 ms
199,452 KB |
testcase_58 | AC | 390 ms
169,360 KB |
testcase_59 | AC | 156 ms
91,132 KB |
testcase_60 | AC | 128 ms
98,920 KB |
testcase_61 | AC | 248 ms
118,212 KB |
testcase_62 | AC | 485 ms
201,136 KB |
testcase_63 | AC | 299 ms
126,740 KB |
testcase_64 | AC | 1,828 ms
451,348 KB |
testcase_65 | AC | 164 ms
89,640 KB |
testcase_66 | AC | 1,031 ms
395,688 KB |
ソースコード
import heapq INF = 1 << 60 n, s, t, k = map(int, input().split()) s -= 1 t -= 1 x = list(map(int, input().split())) m = int(input()) edges = [] idx = {} vs = [s, (k - 1) * n + t] idx[vs[0]] = 0 idx[vs[1]] = 1 src = 0 dst = 1 for _ in range(m): a, b, y = map(int, input().split()) a -= 1 b -= 1 for i in range(k): u = i * n + a v = min(i + 1, k - 1) * n + b if idx.get(u, None) is None: idx[u] = len(idx) vs.append(u) if idx.get(v, None) is None: idx[v] = len(idx) vs.append(v) edges.append((idx[u], idx[v], y + x[b])) g = [[] for _ in range(len(idx))] for u, v, w in edges: g[u].append((v, w)) dist = [INF for _ in range(len(idx))] dist[src] = x[s] prev = [None for _ in range(len(idx))] hp = [(dist[src], src)] while len(hp) > 0: cd, cur = heapq.heappop(hp) if cd > dist[cur]: continue for nxt, cost in g[cur]: if dist[cur] + cost < dist[nxt]: dist[nxt] = dist[cur] + cost prev[nxt] = cur heapq.heappush(hp, (dist[nxt], nxt)) if dist[dst] < INF: print("Possible") print(dist[dst]) cur = dst order = [] while not cur is None: order.append(vs[cur] % n + 1) cur = prev[cur] order.reverse() print(len(order)) print(*order, sep=" ") else: print("Impossible")