結果

問題 No.1683 Robot Guidance
ユーザー 👑 tamatotamato
提出日時 2021-09-17 22:00:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,867 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 87,532 KB
実行使用メモリ 100,204 KB
最終ジャッジ日時 2023-09-12 07:32:33
合計ジャッジ時間 10,483 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
99,784 KB
testcase_01 AC 156 ms
99,660 KB
testcase_02 AC 153 ms
99,840 KB
testcase_03 AC 162 ms
99,888 KB
testcase_04 AC 163 ms
100,080 KB
testcase_05 AC 164 ms
99,920 KB
testcase_06 AC 170 ms
99,940 KB
testcase_07 AC 160 ms
100,080 KB
testcase_08 AC 172 ms
99,948 KB
testcase_09 AC 165 ms
100,004 KB
testcase_10 AC 166 ms
100,096 KB
testcase_11 AC 166 ms
99,856 KB
testcase_12 AC 177 ms
99,936 KB
testcase_13 AC 145 ms
99,584 KB
testcase_14 AC 173 ms
99,832 KB
testcase_15 AC 163 ms
100,036 KB
testcase_16 AC 152 ms
99,532 KB
testcase_17 AC 153 ms
99,604 KB
testcase_18 AC 152 ms
99,516 KB
testcase_19 AC 147 ms
99,696 KB
testcase_20 AC 150 ms
99,588 KB
testcase_21 WA -
testcase_22 AC 145 ms
99,704 KB
testcase_23 AC 144 ms
99,684 KB
testcase_24 AC 175 ms
99,920 KB
testcase_25 WA -
testcase_26 AC 165 ms
100,068 KB
testcase_27 AC 152 ms
99,588 KB
testcase_28 AC 155 ms
99,880 KB
testcase_29 AC 153 ms
99,936 KB
testcase_30 AC 150 ms
99,604 KB
testcase_31 AC 149 ms
99,708 KB
testcase_32 AC 152 ms
99,524 KB
testcase_33 AC 154 ms
99,584 KB
testcase_34 WA -
testcase_35 AC 151 ms
99,788 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 159 ms
99,852 KB
testcase_39 AC 153 ms
99,580 KB
testcase_40 AC 152 ms
99,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    # comb init
    # mod = 1000000007
    nmax = 10 ** 6 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    a, b, x, y = map(int, input().split())
    if (x + y)%2 != a % 2:
        print(0)
        exit()

    if b == 0:
        if a == x and y == 0:
            print(1)
        else:
            print(0)
        exit()
    if b == 1:
        if x < 0 or y < 0:
            print(0)
        elif a != x + y:
            print(0)
        else:
            print(1)
        exit()
    if b == 2:
        if y < 0:
            print(0)
        else:
            aa = a - y
            print(1)

    ans = 0
    Z = (a - abs(x) - abs(y)) // 2
    xp = xn = yp = yn = (b+1) // 4
    if b%4 == 0:
        xp += 1
    elif b%4 == 1:
        xp += 1
        yp += 1
    elif b%4 == 2:
        xp += 1
        yp += 1
        xn += 1
    for zx in range(Z+1):
        zy = Z - zx
        nx = abs(x) + 2 * zx
        ny = abs(y) + 2 * zy
        nxp = (nx + x) // 2
        nxn = nx - nxp
        nyp = (ny + y) // 2
        nyn = ny - nyp
        tmp = 1
        tmp = (tmp * comb(xp + nxp - 1, xp-1))%mod
        tmp = (tmp * comb(xn + nxn - 1, xn - 1)) % mod
        tmp = (tmp * comb(yp + nyp - 1, yp - 1)) % mod
        tmp = (tmp * comb(yn + nyn - 1, yn - 1)) % mod
        ans = (ans + tmp)%mod
    print(ans)


if __name__ == '__main__':
    main()
0