結果

問題 No.2146 2 Pows
ユーザー sotanishysotanishy
提出日時 2022-12-03 00:24:23
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 668 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 326,648 KB
最終ジャッジ日時 2024-04-18 09:31:49
合計ジャッジ時間 5,690 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
67,840 KB
testcase_01 AC 56 ms
65,792 KB
testcase_02 AC 39 ms
59,136 KB
testcase_03 AC 44 ms
61,056 KB
testcase_04 AC 62 ms
67,840 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N, A, B, C = map(int, input().split())
L = 31
ans = [10**18] * N
dist = [10**18] * (N*L)

heap = []
for z in range(L):
    heappush(heap, (A+B+z*C, N*z+(2**z)%N))

while heap:
    d, v = heappop(heap)
    if d > dist[v]:
        continue
    z, i = divmod(v, N)
    ans[i] = min(ans[i], d)

    # same
    nd, u = d+A, N*z+(i+2**z)%N
    if dist[u] > nd:
        dist[u] = nd
        heappush(heap, (nd, u))

    # change
    for w in range(z+1, L):
        nd, u = d+B+(w-z)*C, N*w+i
        if dist[u] > nd:
            dist[u] = nd
            heappush(heap, (nd, u))

print(*ans, sep="\n")
0