結果

問題 No.2146 2 Pows
ユーザー sotanishysotanishy
提出日時 2022-12-03 00:17:44
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 888 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 82,632 KB
実行使用メモリ 849,440 KB
最終ジャッジ日時 2024-04-18 09:26:02
合計ジャッジ時間 5,160 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
59,996 KB
testcase_01 AC 56 ms
67,352 KB
testcase_02 AC 37 ms
54,664 KB
testcase_03 AC 46 ms
62,176 KB
testcase_04 AC 64 ms
70,328 KB
testcase_05 MLE -
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 #

import sys
input = sys.stdin.readline

def dijkstra(G, s):
    from heapq import heappush, heappop

    INF = 10**18
    dist = [INF] * len(G)
    dist[s] = 0
    pq = [(0, s)]
    while pq:
        d, v = heappop(pq)
        if d > dist[v]:
            continue
        for u, weight in G[v]:
            nd = d + weight
            if dist[u] > nd:
                dist[u] = nd
                heappush(pq, (nd, u))
    return dist

N, A, B, C = map(int, input().split())
L = 31
G = [[] for _ in range(N*L+1)]
for z in range(L):
    for i in range(N):
        j = (i + 2**z) % N
        G[N*z+i].append((N*z+j, A))
        for w in range(z+1, L):
            G[N*z+i].append((N*w+i, B+(w-z)*C))
    G[N*L].append((N*z+(2**z)%N, A+B+z*C))
dist = dijkstra(G, N*L)
ans = [10**18] * N
for z in range(L):
    for i in range(N):
        ans[i] = min(ans[i], dist[N*z+i])
print(*ans, sep="\n")
0