結果
| 問題 |
No.2146 2 Pows
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-17 12:04:09 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 497 ms / 3,000 ms |
| コード長 | 2,612 bytes |
| コンパイル時間 | 5,766 ms |
| コンパイル使用メモリ | 335,236 KB |
| 実行使用メモリ | 42,356 KB |
| 最終ジャッジ日時 | 2025-07-17 12:04:28 |
| 合計ジャッジ時間 | 17,007 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
// // 多倍長テンプレ
// /* ---------------------- ここから ---------------------- */
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// // 任意長整数型
// using Bint = mp::cpp_int;
// // 仮数部が10進数で1024桁の浮動小数点数型(TLEしたら小さくする)
// using Real = mp::number<mp::cpp_dec_float<1024>>;
// /* ---------------------- ここまで ---------------------- */
using mint = modint998244353;
// using mint = modint1000000007;
ll mod = 998244353;
// ll mod = 1000000007;
ll inf = 2e18;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(a) (a).begin(), (a).end()
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
vector<pll> G[500009];
ll cost[500009];
ll ans[500009];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
ll n,a,b,c;
cin>>n>>a>>b>>c;
rep(i,n){
G[i].emplace_back((i+1)%n+n,a+b);
}
rep(i,n){
G[n+i].emplace_back((i+1)%n+n,a);
}
rep1(i,n-1){
G[i].emplace_back(2*i%n,c);
G[n+i].emplace_back(2*i%n,c);
}
rep(i,2*n)cost[i] = inf;
priority_queue<pll,vector<pll>,greater<pll>> que;
que.push({0,0});
while(!que.empty()){
pll c = que.top();
que.pop();
if(c.first > cost[c.second])continue;
for(auto v : G[c.second]){
ll u = c.first + v.second;
if(cost[v.first] <= u)continue;
cost[v.first] = u;
que.push({u,v.first});
}
}
rep(i,n){
ans[i] = min(cost[i],cost[n+i]);
}
// rep(i,2*n)cost[i] = inf;
// que.push({0,0});
// while(!que.empty()){
// pll c = que.top();
// que.pop();
// if(c.first > cost[c.second])continue;
// for(auto v : G[c.second]){
// ll u = c.first + v.second;
// if(cost[v.first] <= u)continue;
// cost[v.first] = u;
// que.push({u,v.first});
// }
// }
// rep(i,2*n)cout << cost[i] << endl;
// ans[0] = min(cost[0],cost[n]);
rep(i,n)cout << ans[i] << endl;
}