結果

問題 No.1545 [Cherry 2nd Tune N] Anthem
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-06-12 16:20:22
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 2,124 ms / 3,000 ms
コード長 913 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 231,140 KB
最終ジャッジ日時 2023-08-22 14:13:28
合計ジャッジ時間 34,896 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,384 KB
testcase_01 AC 74 ms
71,320 KB
testcase_02 AC 73 ms
71,328 KB
testcase_03 AC 74 ms
71,288 KB
testcase_04 AC 279 ms
116,940 KB
testcase_05 AC 599 ms
159,428 KB
testcase_06 AC 409 ms
116,240 KB
testcase_07 AC 451 ms
125,640 KB
testcase_08 AC 884 ms
128,224 KB
testcase_09 AC 343 ms
90,340 KB
testcase_10 AC 253 ms
102,332 KB
testcase_11 AC 343 ms
123,216 KB
testcase_12 AC 434 ms
148,288 KB
testcase_13 AC 202 ms
93,472 KB
testcase_14 AC 249 ms
122,840 KB
testcase_15 AC 141 ms
82,812 KB
testcase_16 AC 285 ms
130,316 KB
testcase_17 AC 250 ms
84,136 KB
testcase_18 AC 389 ms
115,988 KB
testcase_19 AC 365 ms
113,768 KB
testcase_20 AC 306 ms
87,188 KB
testcase_21 AC 370 ms
159,296 KB
testcase_22 AC 333 ms
127,864 KB
testcase_23 AC 368 ms
96,140 KB
testcase_24 AC 167 ms
79,172 KB
testcase_25 AC 179 ms
79,544 KB
testcase_26 AC 91 ms
76,612 KB
testcase_27 AC 170 ms
79,248 KB
testcase_28 AC 179 ms
79,280 KB
testcase_29 AC 181 ms
79,544 KB
testcase_30 AC 166 ms
79,096 KB
testcase_31 AC 198 ms
80,428 KB
testcase_32 AC 165 ms
79,156 KB
testcase_33 AC 215 ms
80,556 KB
testcase_34 AC 196 ms
80,688 KB
testcase_35 AC 259 ms
82,588 KB
testcase_36 AC 206 ms
80,952 KB
testcase_37 AC 142 ms
78,032 KB
testcase_38 AC 189 ms
79,604 KB
testcase_39 AC 159 ms
79,152 KB
testcase_40 AC 181 ms
79,488 KB
testcase_41 AC 142 ms
78,684 KB
testcase_42 AC 182 ms
80,120 KB
testcase_43 AC 193 ms
79,596 KB
testcase_44 AC 101 ms
78,964 KB
testcase_45 AC 79 ms
75,536 KB
testcase_46 AC 211 ms
86,104 KB
testcase_47 AC 238 ms
92,452 KB
testcase_48 AC 344 ms
116,300 KB
testcase_49 AC 370 ms
102,308 KB
testcase_50 AC 592 ms
126,428 KB
testcase_51 AC 157 ms
79,188 KB
testcase_52 AC 573 ms
125,784 KB
testcase_53 AC 303 ms
102,304 KB
testcase_54 AC 144 ms
80,488 KB
testcase_55 AC 496 ms
118,124 KB
testcase_56 AC 102 ms
79,476 KB
testcase_57 AC 425 ms
105,784 KB
testcase_58 AC 321 ms
101,560 KB
testcase_59 AC 186 ms
82,256 KB
testcase_60 AC 123 ms
83,484 KB
testcase_61 AC 239 ms
86,148 KB
testcase_62 AC 372 ms
100,360 KB
testcase_63 AC 260 ms
88,420 KB
testcase_64 AC 2,124 ms
231,140 KB
testcase_65 AC 192 ms
81,004 KB
testcase_66 AC 500 ms
222,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

n,s,t,k = map(int,input().split())
s,t = s-1,t-1
X = list(map(int,input().split()))
m = int(input())
e = [[] for i in range(n)]
for i in range(m):
    a,b,y = map(int,input().split())
    e[a-1].append((b-1,y))


inf = 10**20
dis = [[inf]*k for i in range(n)]
par = [[[-1,-1]for _ in range(k) ]for i in range(n)]
dis[s][0] = X[s]
h = [(X[s],s,0)]

while h:
    d,now,l = heappop(h)
    if now == t and l == k-1:
        print("Possible")
        print(d)
        ans = []
        while now != -1:
            ans.append(now+1)
            now,l = par[now][l]
        print(len(ans))
        print(*ans[::-1])
        exit()
    if d != dis[now][l]:
        continue
    for nex, y in e[now]:
        nd = d+y+X[nex]
        nl = min(l+1,k-1)
        if dis[nex][nl] > nd:
            dis[nex][nl] = nd
            heappush(h,(nd,nex,nl))
            par[nex][nl] = [now,l]
print("Impossible")
0