結果
| 問題 | No.2146 2 Pows |
| コンテスト | |
| ユーザー |
sotanishy
|
| 提出日時 | 2022-12-03 00:29:44 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,298 bytes |
| 記録 | |
| コンパイル時間 | 3,384 ms |
| コンパイル使用メモリ | 216,988 KB |
| 実行使用メモリ | 1,108,668 KB |
| 最終ジャッジ日時 | 2026-06-28 17:53:03 |
| 合計ジャッジ時間 | 15,115 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 MLE * 1 -- * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)
#define revrep(i, t, s) for (int i = (int)(t)-1; i >= (int)(s); --i)
#define all(x) begin(x), end(x)
template <typename T> bool chmax(T& a, const T& b) { return a < b ? (a = b, 1) : 0; }
template <typename T> bool chmin(T& a, const T& b) { return a > b ? (a = b, 1) : 0; }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
ll N, A, B, C;
cin >> N >> A >> B >> C;
int L = 31;
vector<ll> ans(N, 1e18), dist(N*L, 1e18);
using P = pair<ll, int>;
priority_queue<P, vector<P>, greater<>> pq;
rep(z,0,L) pq.push({A+B+z*C, N*z+(1LL<<z)%N});
while (!pq.empty()) {
auto [d, v] = pq.top();
pq.pop();
if (d > dist[v]) continue;
int z = v/N, i = v%N;
chmin(ans[i], d);
ll nd = d+A, u = N*z+(i+(1LL<<z))%N;
if (dist[u] > nd) {
dist[u] = nd;
pq.push({nd, u});
}
rep(w,z+1,L) {
ll nd = d+B+(w-z)*C, u = N*w+i;
if (dist[u] > nd) {
dist[u] = nd;
pq.push({nd, u});
}
}
}
rep(i,0,N) cout << ans[i] << "\n";
}
sotanishy