結果

問題 No.2146 2 Pows
ユーザー 沙耶花沙耶花
提出日時 2022-12-02 23:00:09
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 419 ms / 3,000 ms
コード長 1,073 bytes
コンパイル時間 4,668 ms
コンパイル使用メモリ 260,092 KB
実行使用メモリ 18,656 KB
最終ジャッジ日時 2024-04-18 08:17:29
合計ジャッジ時間 13,168 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 320 ms
15,364 KB
testcase_06 AC 371 ms
16,516 KB
testcase_07 AC 315 ms
18,564 KB
testcase_08 AC 377 ms
18,568 KB
testcase_09 AC 419 ms
18,656 KB
testcase_10 AC 5 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 23 ms
5,376 KB
testcase_16 AC 230 ms
11,604 KB
testcase_17 AC 258 ms
12,312 KB
testcase_18 AC 106 ms
7,424 KB
testcase_19 AC 312 ms
14,228 KB
testcase_20 AC 327 ms
14,752 KB
testcase_21 AC 141 ms
9,092 KB
testcase_22 AC 329 ms
17,192 KB
testcase_23 AC 300 ms
14,532 KB
testcase_24 AC 254 ms
11,984 KB
testcase_25 AC 266 ms
12,728 KB
testcase_26 AC 369 ms
16,084 KB
testcase_27 AC 337 ms
13,964 KB
testcase_28 AC 249 ms
12,260 KB
testcase_29 AC 93 ms
6,912 KB
testcase_30 AC 224 ms
11,364 KB
testcase_31 AC 304 ms
13,888 KB
testcase_32 AC 51 ms
5,376 KB
testcase_33 AC 280 ms
12,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001
using P = pair<long long,pair<int,int>>;

int main(){
	
	
	long long n,a,b,c;
	cin>>n>>a>>b>>c;
	
	vector dis(n,vector<long long>(2,Inf64));
	
	dis[1][1] = a+b;
	priority_queue<P,vector<P>,greater<P>> Q;
	Q.emplace(a+b,make_pair(1,1));
	while(Q.size()>0){
		long long D = Q.top().first;
		int x = Q.top().second.first;
		int y = Q.top().second.second;
		Q.pop();
		if(dis[x][y]!=D)continue;
		{
			int nx = (x+1)%n;
			int ny = y;
			long long nD = D + a;
			if(y==0){
				ny = 1;
				nD += b;
			}
			if(dis[nx][ny]>nD){
				dis[nx][ny] = nD;
				Q.emplace(nD,make_pair(nx,ny));
			}
		}
		
		{
			int nx = (x*2)%n;
			int ny = 0;
			long long nD = D + c;
			if(dis[nx][ny]>nD){
				dis[nx][ny] = nD;
				Q.emplace(nD,make_pair(nx,ny));
			}
		}
		
	}
	
	rep(i,n){
		cout<<min(dis[i][0],dis[i][1])<<endl;
	}
	
	return 0;
}
0