結果

問題 No.1985 [Cherry 4th Tune] Early Summer Rain
ユーザー 👑 potato167potato167
提出日時 2022-05-27 02:39:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 996 ms / 7,000 ms
コード長 3,715 bytes
コンパイル時間 4,796 ms
コンパイル使用メモリ 241,896 KB
実行使用メモリ 19,364 KB
最終ジャッジ日時 2024-04-17 12:40:59
合計ジャッジ時間 30,329 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 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 2 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 53 ms
5,376 KB
testcase_15 AC 146 ms
7,372 KB
testcase_16 AC 332 ms
11,548 KB
testcase_17 AC 58 ms
7,512 KB
testcase_18 AC 213 ms
11,020 KB
testcase_19 AC 641 ms
18,432 KB
testcase_20 AC 288 ms
17,428 KB
testcase_21 AC 679 ms
18,292 KB
testcase_22 AC 216 ms
7,564 KB
testcase_23 AC 15 ms
5,376 KB
testcase_24 AC 996 ms
18,468 KB
testcase_25 AC 923 ms
18,468 KB
testcase_26 AC 935 ms
18,596 KB
testcase_27 AC 936 ms
18,468 KB
testcase_28 AC 913 ms
19,240 KB
testcase_29 AC 935 ms
18,500 KB
testcase_30 AC 910 ms
19,236 KB
testcase_31 AC 890 ms
19,364 KB
testcase_32 AC 902 ms
19,236 KB
testcase_33 AC 914 ms
18,596 KB
testcase_34 AC 913 ms
18,596 KB
testcase_35 AC 908 ms
19,236 KB
testcase_36 AC 930 ms
18,472 KB
testcase_37 AC 909 ms
18,592 KB
testcase_38 AC 895 ms
19,364 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 516 ms
18,068 KB
testcase_41 AC 534 ms
16,788 KB
testcase_42 AC 874 ms
19,236 KB
testcase_43 AC 902 ms
18,468 KB
testcase_44 AC 899 ms
19,236 KB
testcase_45 AC 913 ms
18,468 KB
testcase_46 AC 531 ms
17,940 KB
testcase_47 AC 550 ms
16,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=2167167167167167167;
const int INF=2100000000;
const ll mod=998244353;
#define rep(i,a) for (ll i=0;i<a;i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}
template<class T> void vec_out(vector<T> &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}

# include <atcoder/convolution>
using namespace atcoder;



//参考 https://nyaannyaan.github.io/library/fps/formal-power-series.hpp.html
namespace po167{

long long rev(long long a,long long MOD){
    long long D=1,C=MOD-2;
    while(C){
        if(C&1) D=(D*a)%MOD;
        C>>=1;
        a=(a*a)%MOD;
    }
    return D;
}
std::vector<long long> differential_Polynomial(std::vector<long long> p){
	int N=p.size();
	std::vector<long long> r(N);
	for(int i=1;i<N;i++){
		r[i-1]=((long long)(i)*p[i])%mod;
	}
	return r;
}

template <unsigned int mod = 998244353>
std::vector<long long> Integral_Polynomial(std::vector<long long> p){
	int N=p.size();
	std::vector<long long> r(1+N);
	std::vector<long long> rev(N+1,1);
	for(int i=0;i<N;i++){
		if(i+1>1){
			rev[i+1]=(mod-((mod/(i+1))*rev[mod%(i+1)])%mod)%mod;
		}
		r[i+1]=(rev[i+1]*p[i])%mod;
	}
	return r;
}

// return f^{-1} mod x^{L}
// https://judge.yosupo.jp/submission/79004
template <unsigned int mod = 998244353>
std::vector<long long> inv_FPS(int N,int L,std::vector<long long> &p){
	assert((int)p.size()==N);
	assert(0<N);
	assert(p[0]%mod!=0);
	std::vector<long long> q={1},tmp,tmp2;
	long long D=p[0];
	long long C=mod-2;
	while(C){
		if(C&1){
			q[0]=(q[0]*D)%mod;
		}
		C>>=1;
		D=(D*D)%mod;
	}
	int S=1;
	while(S<L){
		S*=2;
		tmp.assign(S,0);
		for(int i=0;i<std::min((int)(p.size()),S);i++) tmp[i]=p[i];
		tmp2=convolution<mod>(tmp,convolution<mod>(q,q));
		for(int i=0;i<S;i++){
			if(i*2<S) tmp[i]=(2ll*q[i]-tmp2[i]+mod)%mod;
			else tmp[i]=(-tmp2[i]+mod)%mod;
		}
		swap(tmp,q);
	}
	std::vector<long long> ans(S);
	for(int i=0;i<S;i++) ans[i]=q[i];
	return ans;
}

}


void solve();

// 僕なんか
int main() {
	int t=1;
	//cin>>t;
	rep(i,t) solve();
}

void solve(){
	int N,K;
	cin>>N>>K;
	vector<ll> E(N+1),F(N+1);
	rep(i,N) cin>>E[i+1],F[i+1]=(mod-E[i+1])%mod;
	F[0]=1;
	auto ans0=po167::inv_FPS(1+N,N+167,F);
	ans0[0]=0;
	vector<ll> X,Y;
	auto _E=po167::differential_Polynomial(E);
	rep(i,N){
		if(_E[i]!=0){
			X.resize(N+1-i);
			Y.resize(N-i);
			rep(j,N-i){
				Y[j]=_E[j+i];
				X[j+1]=E[j+i+1];
			}
			break;
		}
	}
	auto Y_inv=po167::inv_FPS((int)(Y).size(),N+3,Y);
	while(K>0){
		ans0=po167::differential_Polynomial(ans0);
		ans0=convolution(ans0,X);
		ans0.resize(N+167);
		ans0=convolution(ans0,Y_inv);
		ans0.resize(N+167);
		K--;
	}
	X.erase(X.begin());
	auto X_inv=po167::inv_FPS(X.size(),N+167,X);
	while(K<0){
		ans0.erase(ans0.begin());
		ans0=convolution(ans0,X_inv);
		ans0.resize(N+167);
		ans0=convolution(ans0,Y);
		ans0.resize(N+167);
		ans0=po167::Integral_Polynomial(ans0);
		K++;
	}
	rep(i,N){
		if(i!=0) cout<<" ";
		cout<<ans0[i+1];
	}
	cout<<"\n";
}
0