結果

問題 No.1683 Robot Guidance
ユーザー chocoruskchocorusk
提出日時 2021-09-17 21:44:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,461 bytes
コンパイル時間 3,492 ms
コンパイル使用メモリ 188,360 KB
実行使用メモリ 34,976 KB
最終ジャッジ日時 2023-09-12 07:10:36
合計ジャッジ時間 6,949 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
34,660 KB
testcase_01 AC 47 ms
34,644 KB
testcase_02 AC 47 ms
34,652 KB
testcase_03 AC 47 ms
34,708 KB
testcase_04 AC 47 ms
34,652 KB
testcase_05 AC 48 ms
34,704 KB
testcase_06 AC 50 ms
34,648 KB
testcase_07 AC 49 ms
34,724 KB
testcase_08 AC 60 ms
34,644 KB
testcase_09 AC 48 ms
34,708 KB
testcase_10 AC 54 ms
34,720 KB
testcase_11 AC 53 ms
34,724 KB
testcase_12 AC 60 ms
34,656 KB
testcase_13 AC 48 ms
34,852 KB
testcase_14 AC 57 ms
34,648 KB
testcase_15 AC 50 ms
34,640 KB
testcase_16 AC 48 ms
34,776 KB
testcase_17 AC 47 ms
34,660 KB
testcase_18 AC 47 ms
34,652 KB
testcase_19 AC 47 ms
34,708 KB
testcase_20 AC 47 ms
34,728 KB
testcase_21 AC 47 ms
34,656 KB
testcase_22 AC 46 ms
34,656 KB
testcase_23 AC 49 ms
34,784 KB
testcase_24 AC 61 ms
34,644 KB
testcase_25 AC 49 ms
34,652 KB
testcase_26 AC 48 ms
34,720 KB
testcase_27 AC 49 ms
34,660 KB
testcase_28 AC 49 ms
34,660 KB
testcase_29 AC 48 ms
34,656 KB
testcase_30 AC 48 ms
34,648 KB
testcase_31 AC 48 ms
34,720 KB
testcase_32 AC 49 ms
34,724 KB
testcase_33 AC 51 ms
34,652 KB
testcase_34 AC 52 ms
34,704 KB
testcase_35 AC 51 ms
34,976 KB
testcase_36 AC 51 ms
34,776 KB
testcase_37 AC 48 ms
34,724 KB
testcase_38 AC 48 ms
34,720 KB
testcase_39 AC 49 ms
34,824 KB
testcase_40 AC 47 ms
34,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
mint f[4000010], invf[4000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int a, b, x, y;
int main()
{
    cin>>a>>b>>x>>y;
    fac(4000000);
    mint ans=0;
    for(int p=0; p<=a; p++){
        int q=a-p;
        if((x+p)%2!=0 || (y+q)%2!=0 || x+p<0 || p-x<0 || y+q<0 || q-y<0)continue;
        int c[4]={b/4,b/4,b/4,b/4};
        for(int j=0; j<b%4+1; j++) c[j]++;
        int d[4]={(x+p)/2,(y+q)/2,(p-x)/2,(q-y)/2};
        mint z=1;
        for(int j=0; j<4; j++){
            if(c[j]==0 && d[j]==0)continue;
            z*=comb(c[j]-1+d[j], d[j]);
        }
        ans+=z;
    }
    cout<<ans.val()<<endl;
    return 0;
}
0