結果

問題 No.1683 Robot Guidance
ユーザー 沙耶花沙耶花
提出日時 2021-09-17 22:15:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,496 bytes
コンパイル時間 4,426 ms
コンパイル使用メモリ 264,308 KB
実行使用メモリ 28,108 KB
最終ジャッジ日時 2023-09-12 07:57:48
合計ジャッジ時間 21,416 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
27,580 KB
testcase_01 AC 60 ms
27,776 KB
testcase_02 AC 59 ms
27,648 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 72 ms
27,660 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 61 ms
27,724 KB
testcase_20 AC 61 ms
27,596 KB
testcase_21 AC 60 ms
27,656 KB
testcase_22 AC 63 ms
27,584 KB
testcase_23 AC 81 ms
27,576 KB
testcase_24 AC 103 ms
27,600 KB
testcase_25 AC 98 ms
27,724 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 81 ms
27,576 KB
testcase_29 AC 82 ms
27,552 KB
testcase_30 AC 81 ms
27,596 KB
testcase_31 AC 84 ms
27,600 KB
testcase_32 AC 87 ms
27,596 KB
testcase_33 AC 83 ms
27,652 KB
testcase_34 AC 86 ms
27,724 KB
testcase_35 AC 90 ms
27,888 KB
testcase_36 AC 93 ms
27,560 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 60 ms
27,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

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);
	}
	
};
 
int main(){
	
	int A,B,X,Y;
	cin>>A>>B>>X>>Y;
	
	vector<int> d(4,0);
	rep(i,B){
		d[i%4]++;
	}
	combi C(3000000);
	d[B%4]++;
	mint ans = 0;
	rep(i,A+1){
		
		vector<int> c(4,0);
		c[0] = i;
		c[2] = i - X;
		if(c[2]<0)continue;
		int remain = A - c[0] - c[2];
		if(remain<0)continue;
		remain -= abs(Y);
		if(remain%2==1)continue;
		if(Y>=0){
			c[1] = Y + remain/2;
			c[3] = remain/2;
		}
		else{
			c[3] = abs(Y) + remain/2;
			c[1] = remain/2;
		}
		
		mint temp = 1;
		rep(j,4){
			if(c[j]==0&&d[j]==0)continue;
			if(d[j]==0 && c[j]>0){
				temp = 0;
			}
			else{
				temp *= C.combination(c[j]+d[j]-1,c[j]);
			}
		}
		ans += temp;
		
	}
	
	cout<<ans.val()<<endl;
	
	return 0;
}
0