結果

問題 No.1683 Robot Guidance
ユーザー otoshigootoshigo
提出日時 2021-09-18 14:48:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 291 ms / 2,000 ms
コード長 1,796 bytes
コンパイル時間 4,224 ms
コンパイル使用メモリ 262,072 KB
実行使用メモリ 19,100 KB
最終ジャッジ日時 2023-09-13 01:30:55
合計ジャッジ時間 17,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 275 ms
18,376 KB
testcase_01 AC 275 ms
18,656 KB
testcase_02 AC 275 ms
19,100 KB
testcase_03 AC 276 ms
18,520 KB
testcase_04 AC 277 ms
18,508 KB
testcase_05 AC 276 ms
18,712 KB
testcase_06 AC 278 ms
18,516 KB
testcase_07 AC 277 ms
18,468 KB
testcase_08 AC 289 ms
18,644 KB
testcase_09 AC 278 ms
18,548 KB
testcase_10 AC 281 ms
18,572 KB
testcase_11 AC 285 ms
18,320 KB
testcase_12 AC 289 ms
18,648 KB
testcase_13 AC 276 ms
18,464 KB
testcase_14 AC 286 ms
18,852 KB
testcase_15 AC 280 ms
18,568 KB
testcase_16 AC 277 ms
18,396 KB
testcase_17 AC 276 ms
18,648 KB
testcase_18 AC 275 ms
18,716 KB
testcase_19 AC 275 ms
18,776 KB
testcase_20 AC 275 ms
18,708 KB
testcase_21 AC 274 ms
18,616 KB
testcase_22 AC 275 ms
18,472 KB
testcase_23 AC 277 ms
18,532 KB
testcase_24 AC 291 ms
18,492 KB
testcase_25 AC 277 ms
18,552 KB
testcase_26 AC 277 ms
18,740 KB
testcase_27 AC 278 ms
18,704 KB
testcase_28 AC 277 ms
18,676 KB
testcase_29 AC 277 ms
18,540 KB
testcase_30 AC 277 ms
18,420 KB
testcase_31 AC 276 ms
18,520 KB
testcase_32 AC 277 ms
18,320 KB
testcase_33 AC 277 ms
18,648 KB
testcase_34 AC 277 ms
18,580 KB
testcase_35 AC 277 ms
18,740 KB
testcase_36 AC 277 ms
18,536 KB
testcase_37 AC 277 ms
18,332 KB
testcase_38 AC 276 ms
18,824 KB
testcase_39 AC 277 ms
18,716 KB
testcase_40 AC 275 ms
18,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;  using vvi = vector<vi>;
using vl = vector<ll>;   using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>;
using vm = vector<mint>; using vvm = vector<vm>;
using vpi = vector<pii>; using vvpi = vector<vpi>;
using vpl = vector<pll>; using vvpl = vector<vpl>;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
#define rep(i,m,n) for (int i = m; i < (int)(n); i++)
#define rrep(i,m,n) for (int i = m; i > (int)(n); i--)

const int MAX = 2000001; //nの最大

vm fac(MAX),finv(MAX);

void set_fac(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    rep(i,2,MAX){
        fac[i] = fac[i-1]*i;
        finv[i] = finv[i-1] * mint(i).inv();
    }
}

mint cmb(int n,int k){
    if (k < 0) return 1;
    return fac[n]*finv[n-k]*finv[k];
}

int main(){
    set_fac();
    int a,b,x,y; cin >> a >> b >> x >> y;
    vi s(4,(b+1)/4-1);
    rep(i,0,(b+1)%4){
        s[i]++;
    }
    //cout << s[0] << s[1] << s[2] << s[3] << endl;
    mint ans = 0;
    rep(i,0,a+1){
        int j = a - i;
        if ((i+x)%2 == 1 || (j+y)%2 == 1) continue;
        //cout << i << " " << j << endl;
        if (i+x < 0 || i-x < 0 || j+y < 0 || j-y < 0) continue;
        int x0 = (i+x)/2,x2 = (i-x)/2,y1 = (j+y)/2,y3 = (j-y)/2;
        if (x0 > 0 && b < 0) continue;
        if (x2 > 0 && b < 2) continue;
        if (y1 > 0 && b < 1) continue;
        if (y3 > 0 && b < 3) continue;
        ans += cmb(x0+s[0],s[0])*cmb(x2+s[2],s[2])*cmb(y1+s[1],s[1])*cmb(y3+s[3],s[3]);
    }
    cout << ans.val() << endl;
}
0