結果
問題 | No.940 ワープ ε=ε=ε=ε=ε=│;p>д<│ |
ユーザー | 沙耶花 |
提出日時 | 2023-01-25 15:27:47 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,374 ms / 5,000 ms |
コード長 | 2,372 bytes |
コンパイル時間 | 5,085 ms |
コンパイル使用メモリ | 278,344 KB |
実行使用メモリ | 173,152 KB |
最終ジャッジ日時 | 2024-06-26 20:01:43 |
合計ジャッジ時間 | 15,123 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
27,904 KB |
testcase_01 | AC | 60 ms
27,968 KB |
testcase_02 | AC | 60 ms
28,032 KB |
testcase_03 | AC | 64 ms
28,416 KB |
testcase_04 | AC | 60 ms
27,904 KB |
testcase_05 | AC | 60 ms
28,288 KB |
testcase_06 | AC | 61 ms
28,032 KB |
testcase_07 | AC | 61 ms
28,032 KB |
testcase_08 | AC | 59 ms
28,032 KB |
testcase_09 | AC | 60 ms
28,152 KB |
testcase_10 | AC | 60 ms
28,032 KB |
testcase_11 | AC | 59 ms
27,904 KB |
testcase_12 | AC | 61 ms
28,160 KB |
testcase_13 | AC | 61 ms
28,160 KB |
testcase_14 | AC | 59 ms
27,904 KB |
testcase_15 | AC | 134 ms
37,204 KB |
testcase_16 | AC | 230 ms
56,548 KB |
testcase_17 | AC | 695 ms
94,720 KB |
testcase_18 | AC | 718 ms
110,076 KB |
testcase_19 | AC | 697 ms
94,292 KB |
testcase_20 | AC | 744 ms
129,216 KB |
testcase_21 | AC | 381 ms
68,860 KB |
testcase_22 | AC | 743 ms
125,104 KB |
testcase_23 | AC | 364 ms
61,924 KB |
testcase_24 | AC | 744 ms
127,516 KB |
testcase_25 | AC | 1,360 ms
161,008 KB |
testcase_26 | AC | 1,374 ms
173,152 KB |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint1000000007; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 struct combi{ deque<mint> kaijou; deque<mint> kaijou_; combi(int n){ kaijou.push_back(1); for(int i=1;i<=n;i++){ kaijou.push_back(kaijou[i-1]*i); } mint b=kaijou[n].inv(); kaijou_.push_front(b); for(int i=1;i<=n;i++){ int k=n+1-i; kaijou_.push_front(kaijou_[0]*k); } } mint combination(int n,int r){ if(r>n)return 0; mint a = kaijou[n]*kaijou_[r]; a *= kaijou_[n-r]; return a; } mint junretsu(int a,int b){ mint x = kaijou_[a]*kaijou_[b]; x *= kaijou[a+b]; return x; } mint catalan(int n){ return combination(2*n,n)/(n+1); } }; template <class T> vector<T> convolution_mint(vector<T> a,vector<T> b){ static constexpr unsigned long long M0 = 998244353; static constexpr unsigned long long M1 = 754974721; static constexpr unsigned long long M2 = 469762049; vector<long long> aa(a.size()),bb(b.size()); rep(i,a.size())aa[i] = a[i].val(); rep(i,b.size())bb[i] = b[i].val(); auto c0 = convolution<M0>(aa,bb); auto c1 = convolution<M1>(aa,bb); auto c2 = convolution<M2>(aa,bb); vector<mint> ret(c0.size()); rep(i,c0.size()){ ret[i] += c0[i]; { long long cur = c0[i]; cur %= M1; cur = c1[i]-cur; if(cur<0)cur += M1; cur *= 416537774; cur %= M1; mint m = M0; ret[i] += m*cur; cur *= M0; cur += c0[i]; cur %= M2; cur = c2[i] - cur; if(cur<0)cur += M2; cur *= 429847628; cur %= M2; m *= M1; ret[i] += m * cur; } } return ret; } combi C(3000000); int main(){ int X,Y,Z; cin>>X>>Y>>Z; if(X==0&&Y==0&&Z==0){ cout<<1<<endl; return 0; } vector<mint> t(X+Y+Z+1); auto s= t; for(int i=1;i<t.size();i++){ t[i] = 1; t[i] *= C.junretsu(X,i-1); t[i] *= C.junretsu(Y,i-1); t[i] *= C.junretsu(Z,i-1); t[i] *= C.kaijou_[i]; s[i] = C.kaijou_[i]; if(i%2==1)s[i] *= -1; } s[0] = 1; /* rep(i,t.size()){ cout<<t[i].val()<<','<<s[i].val()<<endl; } cout<<endl; */ mint p = 0; auto ans = convolution_mint(t,s); rep(i,X+Y+Z+1){ ans[i] *= C.kaijou[i]; //cout<<ans[i].val()<<endl; p += ans[i]; } cout<<p.val()<<endl; return 0; }