結果

問題 No.1683 Robot Guidance
ユーザー inksamuraiinksamurai
提出日時 2021-09-18 01:14:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,513 bytes
コンパイル時間 1,545 ms
コンパイル使用メモリ 167,428 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 11:30:50
合計ジャッジ時間 7,196 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 13 ms
4,376 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 16 ms
4,380 KB
testcase_17 AC 3 ms
4,384 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 24 ms
4,376 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define fi first
#define se second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end());
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define vec(...) vector<__VA_ARGS__>
#define _3E8xdS5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//eodefine
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vec(int);
using vll=vec(ll);
const int mxn=50000;

//snuke's modular int
template <ll mod>
struct modularint{
	ll x;
	modularint(ll x=0):x(x%mod){}
	modularint& operator+=(const modularint a){
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	modularint& operator-=(const modularint a){
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	modularint& operator*=(const modularint a){
		(x *= a.x) %= mod;
		return *this;
	}
	modularint operator+(const modularint a)const{
		modularint res(*this);
		return res+=a;
	}
	modularint operator-(const modularint a)const{
		modularint res(*this);
		return res-=a;
	}
	modularint operator*(const modularint a)const{
		modularint res(*this);
		return res*=a;
	}
	modularint pow(ll n)const{
		modularint res=1,x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	modularint inv()const{
		return pow(mod-2);
	}
};
using mint=modularint<1000000007>;

mint fact[mxn+10];
void prefact(){
fact[0]=fact[1]=1;
  crep(i,2,mxn){
    mint x=i;
    fact[i]=fact[i-1]*x;
  }
}

mint cnk(ll k,ll n){
  if(k>n) return 0;
  mint e=fact[k]*fact[n-k];
  return fact[n] * e.inv();
}

int main(){
_3E8xdS5;
prefact();
	int a,b,x,y;
	cin>>a>>b>>x>>y;
	vi rbts;
	rep(i,4){
		rbts.pb(b/4);
	}
	int z=b%4;
	rep(i,z+1){
		rbts[i]++;
	}
	mint ans=0;
	rep(i,a+1){
		vi nowrbts(4);
		nowrbts[0]=i;
		nowrbts[2]=(i-x);
		ll j=a-(nowrbts[0]+nowrbts[2]);
		if(nowrbts[1]<0) continue;
		if((j-y)%2) continue;
		ll yl=(j-y)/2,yr=(y+yl);
		if(min(yl,yr)<0) continue;
		if(yr-yl!=y) continue;
		nowrbts[3]=yl;
		nowrbts[1]=yr;
		mint now=1;
		rep(j,4){
			if(rbts[j]==0 and nowrbts[j]>0){
				// cout<<j<<"\n";
				now=0;
				break;
			}else if(rbts[j]==0 and nowrbts[j]==0){

			}else{
				now*=cnk(rbts[j]-1,nowrbts[j]+rbts[j]-1);
			}
		}
		ans+=now;
		// printf("\n");
	}
	printf("%lld\n",ans.x);
//	let's fix positive x-es
	return 0;
}
0