結果
| 問題 |
No.2146 2 Pows
|
| コンテスト | |
| ユーザー |
sotanishy
|
| 提出日時 | 2022-12-03 00:17:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 888 bytes |
| コンパイル時間 | 414 ms |
| コンパイル使用メモリ | 82,456 KB |
| 実行使用メモリ | 856,192 KB |
| 最終ジャッジ日時 | 2024-10-10 02:41:48 |
| 合計ジャッジ時間 | 5,401 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 MLE * 1 -- * 28 |
ソースコード
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")
sotanishy