結果
問題 | No.1683 Robot Guidance |
ユーザー | beet |
提出日時 | 2021-09-17 22:05:06 |
言語 | C++23(draft) (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 212 ms / 2,000 ms |
コード長 | 3,765 bytes |
コンパイル時間 | 3,919 ms |
コンパイル使用メモリ | 250,624 KB |
実行使用メモリ | 32,884 KB |
最終ジャッジ日時 | 2023-09-12 07:43:45 |
合計ジャッジ時間 | 11,643 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 173 ms
18,620 KB |
testcase_01 | AC | 203 ms
19,516 KB |
testcase_02 | AC | 205 ms
16,796 KB |
testcase_03 | AC | 207 ms
22,316 KB |
testcase_04 | AC | 201 ms
19,160 KB |
testcase_05 | AC | 205 ms
20,212 KB |
testcase_06 | AC | 204 ms
19,356 KB |
testcase_07 | AC | 203 ms
19,744 KB |
testcase_08 | AC | 203 ms
19,668 KB |
testcase_09 | AC | 189 ms
20,616 KB |
testcase_10 | AC | 203 ms
19,284 KB |
testcase_11 | AC | 203 ms
21,284 KB |
testcase_12 | AC | 195 ms
18,384 KB |
testcase_13 | AC | 81 ms
26,672 KB |
testcase_14 | AC | 195 ms
25,276 KB |
testcase_15 | AC | 137 ms
20,448 KB |
testcase_16 | AC | 205 ms
19,756 KB |
testcase_17 | AC | 206 ms
20,268 KB |
testcase_18 | AC | 205 ms
18,772 KB |
testcase_19 | AC | 174 ms
19,588 KB |
testcase_20 | AC | 175 ms
20,144 KB |
testcase_21 | AC | 187 ms
16,756 KB |
testcase_22 | AC | 207 ms
20,188 KB |
testcase_23 | AC | 153 ms
29,976 KB |
testcase_24 | AC | 212 ms
21,588 KB |
testcase_25 | AC | 185 ms
28,548 KB |
testcase_26 | AC | 46 ms
32,884 KB |
testcase_27 | AC | 126 ms
26,056 KB |
testcase_28 | AC | 154 ms
29,964 KB |
testcase_29 | AC | 152 ms
28,820 KB |
testcase_30 | AC | 156 ms
28,692 KB |
testcase_31 | AC | 132 ms
20,896 KB |
testcase_32 | AC | 137 ms
20,528 KB |
testcase_33 | AC | 143 ms
18,780 KB |
testcase_34 | AC | 154 ms
19,324 KB |
testcase_35 | AC | 158 ms
23,888 KB |
testcase_36 | AC | 171 ms
23,480 KB |
testcase_37 | AC | 170 ms
24,440 KB |
testcase_38 | AC | 177 ms
23,132 KB |
testcase_39 | AC | 119 ms
20,540 KB |
testcase_40 | AC | 38 ms
29,224 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using Int = long long; const char newl = '\n'; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);} template<typename T=int> vector<T> read(size_t n){ vector<T> ts(n); for(size_t i=0;i<n;i++) cin>>ts[i]; return ts; } template<typename T, T MOD = 1000000007> struct Mint{ inline static constexpr T mod = MOD; T v; Mint():v(0){} Mint(signed v):v(v){} Mint(long long t){v=t%MOD;if(v<0) v+=MOD;} Mint pow(long long k){ Mint res(1),tmp(v); while(k){ if(k&1) res*=tmp; tmp*=tmp; k>>=1; } return res; } static Mint add_identity(){return Mint(0);} static Mint mul_identity(){return Mint(1);} Mint inv(){return pow(MOD-2);} Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;} Mint& operator/=(Mint a){return (*this)*=a.inv();} Mint operator+(Mint a) const{return Mint(v)+=a;} Mint operator-(Mint a) const{return Mint(v)-=a;} Mint operator*(Mint a) const{return Mint(v)*=a;} Mint operator/(Mint a) const{return Mint(v)/=a;} Mint operator+() const{return *this;} Mint operator-() const{return v?Mint(MOD-v):Mint(v);} bool operator==(const Mint a)const{return v==a.v;} bool operator!=(const Mint a)const{return v!=a.v;} static Mint comb(long long n,int k){ Mint num(1),dom(1); for(int i=0;i<k;i++){ num*=Mint(n-i); dom*=Mint(i+1); } return num/dom; } }; template<typename T, T MOD> ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;} template<typename M_> class Enumeration{ using M = M_; protected: inline static vector<M> fact,finv,invs; public: static void init(int n){ n=min<decltype(M::mod)>(n,M::mod-1); int m=fact.size(); if(n<m) return; fact.resize(n+1,1); finv.resize(n+1,1); invs.resize(n+1,1); if(m==0) m=1; for(int i=m;i<=n;i++) fact[i]=fact[i-1]*M(i); finv[n]=M(1)/fact[n]; for(int i=n;i>=m;i--) finv[i-1]=finv[i]*M(i); for(int i=m;i<=n;i++) invs[i]=finv[i]*fact[i-1]; } static M Fact(int n){ init(n); return fact[n]; } static M Finv(int n){ init(n); return finv[n]; } static M Invs(int n){ init(n); return invs[n]; } static M C(int n,int k){ if(n<k or k<0) return M(0); init(n); return fact[n]*finv[n-k]*finv[k]; } static M P(int n,int k){ if(n<k or k<0) return M(0); init(n); return fact[n]*finv[n-k]; } // put n identical balls into k distinct boxes static M H(int n,int k){ if(n<0 or k<0) return M(0); if(!n and !k) return M(1); init(n+k); return C(n+k-1,n); } }; //INSERT ABOVE HERE signed main(){ cin.tie(0); ios::sync_with_stdio(0); int a,b,x,y; cin>>a>>b>>x>>y; int p=b/2+1; int q=(b+1)/2; using M = Mint<int>; using E = Enumeration<M>; const int MAX = 1e6+100; vector<M> ss(MAX),ts(MAX); for(int i=0;i<MAX;i++){ { // s + t = i // s - t = -x int s=(i-x)/2; int t=(i+x)/2; int neg=(p+1)/2,pos=p-neg; if(s+t==i and s-t==-x and min(s,t)>=0) ss[i]=E::H(s,pos)*E::H(t,neg); } { // s + t = i // s - t = -y int s=(i-y)/2; int t=(i+y)/2; int neg=(q+1)/2,pos=q-neg; if(s+t==i and s-t==-y and min(s,t)>=0) ts[i]=E::H(s,pos)*E::H(t,neg); } //if(i<10) cout<<i<<':'<<ss[i]<<' '<<ts[i]<<endl; } M ans{0}; for(int i=0;i<=a;i++) ans+=ss[i]*ts[a-i]; cout<<ans<<newl; return 0; }