結果

問題 No.1683 Robot Guidance
ユーザー inksamuraiinksamurai
提出日時 2021-09-17 23:19:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,531 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 167,612 KB
実行使用メモリ 42,836 KB
最終ジャッジ日時 2023-09-12 09:23:45
合計ジャッジ時間 8,759 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
42,736 KB
testcase_01 AC 38 ms
42,536 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 48 ms
42,608 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 42 ms
42,672 KB
testcase_19 AC 39 ms
42,548 KB
testcase_20 AC 39 ms
42,556 KB
testcase_21 AC 39 ms
42,668 KB
testcase_22 AC 38 ms
42,552 KB
testcase_23 AC 149 ms
42,568 KB
testcase_24 WA -
testcase_25 AC 59 ms
42,556 KB
testcase_26 WA -
testcase_27 AC 193 ms
42,560 KB
testcase_28 AC 150 ms
42,732 KB
testcase_29 AC 151 ms
42,776 KB
testcase_30 AC 150 ms
42,568 KB
testcase_31 AC 77 ms
42,580 KB
testcase_32 AC 99 ms
42,548 KB
testcase_33 AC 148 ms
42,628 KB
testcase_34 AC 200 ms
42,548 KB
testcase_35 AC 117 ms
42,564 KB
testcase_36 AC 137 ms
42,568 KB
testcase_37 AC 90 ms
42,552 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 39 ms
42,664 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=5000000;

//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-i;
		if(nowrbts[1]<0) continue;
		if((j-y)%2) continue;
		ll yl=(j-y)/2,yr=(y+yl);
		if(min(yl,yr)<0) 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);
			}
			// cout<<j<<" "<<now.x<<"\n";
			// printf("%d\n",rbts[j]);
		}
		ans+=now;
		// printf("\n");
	}
	printf("%lld\n",ans.x);
//	let's fix positive x-es
	return 0;
}
0