結果
| 問題 |
No.2146 2 Pows
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-15 19:25:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 3,000 ms |
| コード長 | 1,213 bytes |
| コンパイル時間 | 3,491 ms |
| コンパイル使用メモリ | 257,984 KB |
| 実行使用メモリ | 13,880 KB |
| 最終ジャッジ日時 | 2025-07-15 19:25:35 |
| 合計ジャッジ時間 | 7,761 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
struct io_setup {
io_setup() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout << fixed << setprecision(15);
}
} io_setup;
void solve() {
int n, a, b, c;
cin >> n >> a >> b >> c;
vector<array<ll, 2>> vp(n, {(ll)1e18, (ll)1e18});
priority_queue<array<ll, 3>, vector<array<ll, 3>>, greater<array<ll, 3>>>
pq;
pq.push({a + b, 1, 0});
vp[1][0] = a + b;
while (!pq.empty()) {
auto [cs, nw, flg] = pq.top();
pq.pop();
if (vp[nw][flg] < cs) continue;
{
auto ncs = cs + c;
auto nnw = (nw * 2) % n;
if (chmin(vp[nnw][1], ncs)) {
pq.push({ncs, nnw, 1});
}
}
{
auto ncs = cs + a + flg * b;
auto nnw = (nw + 1) % n;
if (chmin(vp[nnw][0], ncs)) {
pq.push({ncs, nnw, 0});
}
}
}
rep(i, 0, n) {
cout << min(vp[i][0], vp[i][1]) << "\n";
}
}
int main() {
int t = 1;
// cin >> t;
while (t--) solve();
}