結果
| 問題 |
No.2146 2 Pows
|
| コンテスト | |
| ユーザー |
sotanishy
|
| 提出日時 | 2022-12-03 00:29:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,298 bytes |
| コンパイル時間 | 2,069 ms |
| コンパイル使用メモリ | 200,824 KB |
| 最終ジャッジ日時 | 2025-02-09 04:34:48 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 10 TLE * 9 MLE * 2 |
ソースコード
#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