結果
問題 | No.1985 [Cherry 4th Tune] Early Summer Rain |
ユーザー | 👑 potato167 |
提出日時 | 2022-05-27 02:39:31 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 974 ms / 7,000 ms |
コード長 | 3,715 bytes |
コンパイル時間 | 4,030 ms |
コンパイル使用メモリ | 249,664 KB |
実行使用メモリ | 19,372 KB |
最終ジャッジ日時 | 2024-10-09 06:42:38 |
合計ジャッジ時間 | 29,726 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 3 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,820 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 4 ms
6,820 KB |
testcase_07 | AC | 4 ms
6,820 KB |
testcase_08 | AC | 5 ms
6,816 KB |
testcase_09 | AC | 3 ms
6,820 KB |
testcase_10 | AC | 4 ms
6,816 KB |
testcase_11 | AC | 4 ms
6,820 KB |
testcase_12 | AC | 3 ms
6,816 KB |
testcase_13 | AC | 2 ms
6,820 KB |
testcase_14 | AC | 54 ms
6,816 KB |
testcase_15 | AC | 145 ms
7,372 KB |
testcase_16 | AC | 355 ms
11,544 KB |
testcase_17 | AC | 62 ms
7,580 KB |
testcase_18 | AC | 228 ms
11,144 KB |
testcase_19 | AC | 670 ms
18,312 KB |
testcase_20 | AC | 282 ms
17,432 KB |
testcase_21 | AC | 659 ms
18,296 KB |
testcase_22 | AC | 205 ms
7,520 KB |
testcase_23 | AC | 14 ms
6,820 KB |
testcase_24 | AC | 974 ms
18,472 KB |
testcase_25 | AC | 966 ms
18,472 KB |
testcase_26 | AC | 974 ms
18,600 KB |
testcase_27 | AC | 964 ms
18,476 KB |
testcase_28 | AC | 947 ms
19,372 KB |
testcase_29 | AC | 967 ms
18,476 KB |
testcase_30 | AC | 948 ms
19,364 KB |
testcase_31 | AC | 941 ms
19,368 KB |
testcase_32 | AC | 937 ms
19,372 KB |
testcase_33 | AC | 958 ms
18,600 KB |
testcase_34 | AC | 961 ms
18,472 KB |
testcase_35 | AC | 942 ms
19,372 KB |
testcase_36 | AC | 966 ms
18,600 KB |
testcase_37 | AC | 972 ms
18,600 KB |
testcase_38 | AC | 947 ms
19,240 KB |
testcase_39 | AC | 2 ms
6,816 KB |
testcase_40 | AC | 556 ms
18,036 KB |
testcase_41 | AC | 571 ms
16,664 KB |
testcase_42 | AC | 918 ms
19,240 KB |
testcase_43 | AC | 944 ms
18,472 KB |
testcase_44 | AC | 950 ms
19,364 KB |
testcase_45 | AC | 962 ms
18,600 KB |
testcase_46 | AC | 551 ms
17,948 KB |
testcase_47 | AC | 574 ms
16,660 KB |
ソースコード
#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"; }