結果
| 問題 | No.2146 2 Pows |
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2022-12-03 01:04:35 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,402 ms / 3,000 ms |
| + 818µs | |
| コード長 | 529 bytes |
| 記録 | |
| コンパイル時間 | 630 ms |
| コンパイル使用メモリ | 80,896 KB |
| 実行使用メモリ | 159,396 KB |
| 最終ジャッジ日時 | 2026-09-12 23:21:01 |
| 合計ジャッジ時間 | 23,888 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
from heapq import*
n,a,b,c=map(int,input().split())
inf=1<<61
dist=[[inf]*2 for i in range(n)]
seen=[[0]*2 for i in range(n)]
hq=[(0,0,0)]
while hq:
d,i,f=heappop(hq)
if dist[i][f]<d:
continue
if i!=0 or f!=0:
seen[i][f]=1
if seen[(i+1)%n][1]==False and d+a+(1-f)*b<dist[(i+1)%n][1]:
dist[(i+1)%n][1]=d+a+(1-f)*b
heappush(hq,(d+a+(1-f)*b,(i+1)%n,1))
if seen[(2*i)%n][0]==False and d+c<dist[(2*i)%n][0] and i!=0:
dist[(2*i)%n][0]=d+c
heappush(hq,(d+c,(2*i)%n,0))
for i in dist:
print(min(i))
とりゐ