結果
問題 | No.940 ワープ ε=ε=ε=ε=ε=│;p>д<│ |
ユーザー | latte0119 |
提出日時 | 2019-12-03 14:05:45 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 8,161 bytes |
コンパイル時間 | 2,530 ms |
コンパイル使用メモリ | 172,180 KB |
実行使用メモリ | 123,264 KB |
最終ジャッジ日時 | 2024-05-06 07:45:53 |
合計ジャッジ時間 | 8,090 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 93 ms
36,736 KB |
testcase_01 | AC | 94 ms
36,736 KB |
testcase_02 | AC | 87 ms
36,736 KB |
testcase_03 | AC | 89 ms
36,736 KB |
testcase_04 | WA | - |
testcase_05 | AC | 91 ms
37,376 KB |
testcase_06 | AC | 93 ms
37,248 KB |
testcase_07 | AC | 92 ms
37,120 KB |
testcase_08 | AC | 96 ms
37,120 KB |
testcase_09 | AC | 93 ms
37,248 KB |
testcase_10 | AC | 94 ms
36,992 KB |
testcase_11 | AC | 93 ms
37,120 KB |
testcase_12 | AC | 94 ms
37,376 KB |
testcase_13 | AC | 98 ms
37,376 KB |
testcase_14 | AC | 93 ms
36,864 KB |
testcase_15 | AC | 213 ms
58,496 KB |
testcase_16 | AC | 628 ms
123,264 KB |
testcase_17 | AC | 98 ms
37,376 KB |
testcase_18 | AC | 96 ms
37,376 KB |
testcase_19 | AC | 95 ms
36,992 KB |
testcase_20 | AC | 96 ms
37,376 KB |
testcase_21 | AC | 94 ms
36,992 KB |
testcase_22 | AC | 341 ms
79,872 KB |
testcase_23 | AC | 625 ms
121,984 KB |
testcase_24 | AC | 348 ms
80,640 KB |
testcase_25 | AC | 625 ms
122,880 KB |
testcase_26 | AC | 627 ms
123,264 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,a,b) for(int i=(a);i<(b);i++) #define pb push_back #define eb emplace_back #define all(v) (v).begin(),(v).end() #define fi first #define se second using vint=vector<int>; using pint=pair<int,int>; using vpint=vector<pint>; template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;} template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;} template<class A,class B> ostream& operator<<(ostream& ost,const pair<A,B>&p){ ost<<"{"<<p.first<<","<<p.second<<"}"; return ost; } template<class T> ostream& operator<<(ostream& ost,const vector<T>&v){ ost<<"{"; for(int i=0;i<v.size();i++){ if(i)ost<<","; ost<<v[i]; } ost<<"}"; return ost; } template<uint32_t mod> struct ModInt{ uint32_t a; ModInt& s(uint32_t vv){ a=vv<mod?vv:vv-mod; return *this; } ModInt(int64_t x=0){s(x%mod+mod);} ModInt& operator+=(const ModInt &x){return s(a+x.a);} ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);} ModInt& operator*=(const ModInt &x){ a=uint64_t(a)*x.a%mod; return *this; } ModInt& operator/=(const ModInt &x){ *this*=x.inv(); return *this; } ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;} ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;} ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;} ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;} bool operator==(const ModInt &x)const{return a==x.a;} bool operator!=(const ModInt &x)const{return a!=x.a;} bool operator<(const ModInt &x)const{return a<x.a;} ModInt operator-()const{return ModInt()-*this;} ModInt pow(int64_t n)const{ ModInt res(1),x(*this); while(n){ if(n&1)res*=x; x*=x; n>>=1; } return res; } ModInt inv()const{return pow(mod-2);} }; template<uint32_t mod> istream& operator>>(istream& in,const ModInt<mod>& a){ return (in>>a.a); } template<uint32_t mod> ostream& operator<<(ostream& out,const ModInt<mod>& a){ return (out<<a.a); } using mint=ModInt<1000000007>; template<class Mint,int32_t lg> struct ModIntTable{ int N; vector<Mint>facts,finvs,invs; ModIntTable():N(1<<lg),facts(N),finvs(N),invs(N){ const uint32_t mod=Mint(-1).a+1; invs[1]=1; for(int i=2;i<N;i++)invs[i]=invs[mod%i]*(mod-mod/i); facts[0]=1; finvs[0]=1; for(int i=1;i<N;i++){ facts[i]=facts[i-1]*i; finvs[i]=finvs[i-1]*invs[i]; } } inline Mint fact(int n)const{return facts[n];} inline Mint finv(int n)const{return finvs[n];} inline Mint inv(int n)const{return invs[n];} inline Mint binom(int n,int k)const{return facts[n]*finvs[k]*finvs[n-k];} inline Mint perm(int n,int k)const{return facts[n]*finvs[n-k];} }; ModIntTable<mint,21>mtable; /* using Cd = complex<double>; namespace std { template<> Cd& Cd::operator*=(const Cd& y) { double a = this->real(); double b = this->imag(); double c = y.real(); double d = y.imag(); return *this=Cd(a*c-b*d, a*d+b*c); } } template<class Mint,class C> struct ArbitraryModConvolution15{ static constexpr double PI=acos(-1); static void dft(vector<C>&f){ int n=f.size(); int s=__lg(n); static vector<vector<C>>w(30); w[0]=vector<C>(1,C(1.0,0.0)); for(int i=1;i<=s;i++){ if(w[i].size())continue; w[i]=vector<C>(1<<i); const double t=2*PI/(1<<i); for(int j=0;j<1<<i;j++)w[i][j]=(j&1)?polar(1.0,j*t):w[i-1][j>>1]; } for(int i=0,j=1;j<n-1;j++){ for(int k=n>>1;k>(i^=k);k>>=1); if(i>j)swap(f[i],f[j]); } for(int m=1;m<=s;m++){ for(int i=0;i<n;i+=1<<m){ for(int j=0;j<1<<m-1;j++){ C f0=f[i+j],f1=w[m][j]*f[i+j+(1<<m-1)]; f[i+j]=f0+f1; f[i+j+(1<<m-1)]=f0-f1; } } } } static void idft(vector<C>&f){ dft(f); reverse(f.begin()+1,f.end()); double in=1.0/f.size(); for(int i=0;i<f.size();i++)f[i]*=in; } static vector<Mint>convolute(vector<Mint>A,vector<Mint>B){ int n=1<<__lg(A.size()+B.size()-2)+1; vector<C>g(n),h(n); for(int i=0;i<A.size();i++)g[i]=C(A[i].a&~(~0<<15),A[i].a>>15); for(int i=0;i<B.size();i++)h[i]=C(B[i].a&~(~0<<15),B[i].a>>15); dft(g); dft(h); vector<C>gc=g; reverse(gc.begin()+1,gc.end()); C I(0,1); for(int i=0;i<n;i++){ gc[i]=conj(gc[i]); C a=(g[i]+gc[i])*h[i]*0.5; C b=(g[i]-gc[i])*h[i]*I*(-0.5); g[i]=a;h[i]=b; } idft(g); idft(h); vector<Mint>AB(A.size()+B.size()-1); for(int i=0;i<AB.size();i++){ Mint ll=g[i].real()+0.5; Mint lh=g[i].imag()+0.5; Mint hl=h[i].real()+0.5; Mint hh=h[i].imag()+0.5; AB[i]=(hh*(1<<15)+(lh+hl))*(1<<15)+ll; } return AB; } }; using FFT=ArbitraryModConvolution15<mint,complex<double>>; */ /* long double ver */ using Cd = complex<long double>; namespace std { template<> Cd& Cd::operator*=(const Cd& y) { long double a = this->real(); long double b = this->imag(); long double c = y.real(); long double d = y.imag(); return *this=Cd(a*c-b*d, a*d+b*c); } } template<class Mint,class C> struct ArbitraryModConvolution15{ static constexpr long double PI=acosl(-1); static void dft(vector<C>&f){ int n=f.size(); int s=__lg(n); static vector<vector<C>>w(30); w[0]=vector<C>(1,C(1.0,0.0)); for(int i=1;i<=s;i++){ if(w[i].size())continue; w[i]=vector<C>(1<<i); const long double t=2*PI/(1<<i); for(int j=0;j<1<<i;j++)w[i][j]=(j&1)?C(cosl(j*t),sinl(j*t)):w[i-1][j>>1]; } for(int i=0,j=1;j<n-1;j++){ for(int k=n>>1;k>(i^=k);k>>=1); if(i>j)swap(f[i],f[j]); } for(int m=1;m<=s;m++){ for(int i=0;i<n;i+=1<<m){ for(int j=0;j<1<<m-1;j++){ C f0=f[i+j],f1=w[m][j]*f[i+j+(1<<m-1)]; f[i+j]=f0+f1; f[i+j+(1<<m-1)]=f0-f1; } } } } static void idft(vector<C>&f){ dft(f); reverse(f.begin()+1,f.end()); long double in=1.0/f.size(); for(int i=0;i<f.size();i++)f[i]*=in; } static vector<Mint>convolute(vector<Mint>A,vector<Mint>B){ int n=1<<__lg(A.size()+B.size()-2)+1; vector<C>g(n),h(n); for(int i=0;i<A.size();i++)g[i]=C(A[i].a&~(~0<<15),A[i].a>>15); for(int i=0;i<B.size();i++)h[i]=C(B[i].a&~(~0<<15),B[i].a>>15); dft(g); dft(h); vector<C>gc=g; reverse(gc.begin()+1,gc.end()); C I(0,1); for(int i=0;i<n;i++){ gc[i]=conj(gc[i]); C a=(g[i]+gc[i])*h[i]*0.5L; C b=(g[i]-gc[i])*h[i]*I*(-0.5L); g[i]=a;h[i]=b; } idft(g); idft(h); vector<Mint>AB(A.size()+B.size()-1); for(int i=0;i<AB.size();i++){ Mint ll=g[i].real()+0.5; Mint lh=g[i].imag()+0.5; Mint hl=h[i].real()+0.5; Mint hh=h[i].imag()+0.5; AB[i]=(hh*(1<<15)+(lh+hl))*(1<<15)+ll; } return AB; } }; using FFT=ArbitraryModConvolution15<mint,complex<long double>>; mint po[2222222]; signed main(){ po[0]=1; for(int i=1;i<2222222;i++)po[i]=po[i-1]*2; int X,Y,Z; cin>>X>>Y>>Z; if(X==0&&Y==0&&Z==0){ cout<<0<<endl; return 0; } vector<mint>F(X+Y+1); for(int i=0;i<=X+Y;i++){ if(i+Z<X||i+Z<Y)continue; F[i]=mtable.binom(i+Z,X)*mtable.binom(i+Z,Y)*mtable.binom(i+Z,Z)*mtable.finv(i+Z); if((i+Z)&1)F[i]*=-1; } vector<mint>U(X+Y+1); for(int i=0;i<=X+Y;i++)U[i]=mtable.finv(i); auto P=FFT::convolute(F,U); mint ans=0; for(int i=0;i<=X+Y;i++){ int k=i+Z; mint tmp=po[k]*mtable.fact(k)*P[i]; ans+=tmp; } ans/=2; if(X&1)ans*=-1; if(Y&1)ans*=-1; if(Z&1)ans*=-1; cout<<ans<<endl; return 0; }