結果

問題 No.1683 Robot Guidance
ユーザー ぷらぷら
提出日時 2021-09-17 22:34:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,661 bytes
コンパイル時間 1,948 ms
コンパイル使用メモリ 199,124 KB
実行使用メモリ 50,552 KB
最終ジャッジ日時 2023-09-12 08:34:06
合計ジャッジ時間 5,873 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
50,168 KB
testcase_01 AC 55 ms
50,172 KB
testcase_02 AC 55 ms
50,212 KB
testcase_03 AC 54 ms
50,428 KB
testcase_04 AC 56 ms
50,468 KB
testcase_05 AC 56 ms
50,480 KB
testcase_06 AC 58 ms
50,192 KB
testcase_07 AC 56 ms
50,216 KB
testcase_08 AC 70 ms
50,212 KB
testcase_09 AC 60 ms
50,272 KB
testcase_10 AC 61 ms
50,440 KB
testcase_11 AC 60 ms
50,196 KB
testcase_12 AC 67 ms
50,216 KB
testcase_13 AC 54 ms
50,344 KB
testcase_14 AC 64 ms
50,168 KB
testcase_15 AC 58 ms
50,244 KB
testcase_16 AC 59 ms
50,164 KB
testcase_17 AC 61 ms
50,224 KB
testcase_18 AC 53 ms
50,196 KB
testcase_19 AC 53 ms
50,436 KB
testcase_20 WA -
testcase_21 AC 58 ms
50,188 KB
testcase_22 AC 53 ms
50,352 KB
testcase_23 AC 54 ms
50,212 KB
testcase_24 AC 72 ms
50,172 KB
testcase_25 AC 55 ms
50,176 KB
testcase_26 AC 56 ms
50,212 KB
testcase_27 AC 58 ms
50,196 KB
testcase_28 WA -
testcase_29 AC 56 ms
50,272 KB
testcase_30 AC 51 ms
50,224 KB
testcase_31 AC 55 ms
50,216 KB
testcase_32 AC 56 ms
50,240 KB
testcase_33 AC 61 ms
50,480 KB
testcase_34 AC 58 ms
50,344 KB
testcase_35 AC 56 ms
50,272 KB
testcase_36 AC 59 ms
50,340 KB
testcase_37 AC 56 ms
50,224 KB
testcase_38 AC 57 ms
50,336 KB
testcase_39 AC 56 ms
50,228 KB
testcase_40 AC 55 ms
50,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int mod = 1000000007;

long long fac[2000005], finv[2000005], inv[2000005];

void COMinit() {
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < 2000005; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long COM(int n, int k) {
    if (n < 0 && k < 0) return 1;
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
    int A,B,X,Y;
    cin >> A >> B >> X >> Y;
    COMinit();
    long long ans = 0;
    int a = 1+B/4;
    int b = min(1,B)+(B-1)/4;
    int c = min(1,B-1)+(B-2)/4;
    int d = min(1,B-2)+(B-3)/4;
    if(A-abs(X)-abs(Y) < 0 || (A-abs(X)-abs(Y))%2 != 0) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = abs(X); i+abs(Y) <= A; i += 2) {
        int e = (i-abs(X))/2,f = i-e;
        long long tmp = 1;
        if(X >= 0) {
            tmp *= COM(a+f-1,a-1);
            tmp *= COM(c+e-1,c-1);
            tmp %= mod;
        }
        else {
            tmp *= COM(c+f-1,c-1);
            tmp *= COM(a+e-1,a-1);
            tmp %= mod;
        }
        e = ((A-i)-abs(Y))/2,f = (A-i)-e;
        if(Y >= 0) {
            tmp *= COM(b+f-1,b-1);
            tmp %= mod;
            tmp *= COM(d+e-1,d-1);
            tmp %= mod;
        }
        else {
            tmp *= COM(d+f-1,d-1);
            tmp %= mod;
            tmp *= COM(b+e-1,b-1);
            tmp %= mod;
        }
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
}
0