結果

問題 No.1683 Robot Guidance
ユーザー asumo0729asumo0729
提出日時 2021-09-17 23:15:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,016 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 273,040 KB
最終ジャッジ日時 2023-09-12 09:18:33
合計ジャッジ時間 25,020 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 506 ms
271,712 KB
testcase_01 AC 507 ms
270,740 KB
testcase_02 AC 510 ms
270,472 KB
testcase_03 AC 531 ms
272,160 KB
testcase_04 AC 525 ms
271,532 KB
testcase_05 AC 544 ms
272,152 KB
testcase_06 AC 570 ms
271,912 KB
testcase_07 AC 550 ms
270,708 KB
testcase_08 AC 714 ms
272,240 KB
testcase_09 AC 544 ms
271,072 KB
testcase_10 AC 617 ms
271,844 KB
testcase_11 AC 613 ms
272,268 KB
testcase_12 AC 705 ms
270,640 KB
testcase_13 AC 520 ms
270,832 KB
testcase_14 AC 655 ms
271,196 KB
testcase_15 AC 550 ms
270,860 KB
testcase_16 AC 523 ms
270,628 KB
testcase_17 AC 516 ms
271,912 KB
testcase_18 AC 522 ms
270,024 KB
testcase_19 AC 519 ms
271,520 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 504 ms
269,712 KB
testcase_23 AC 518 ms
270,144 KB
testcase_24 AC 746 ms
270,716 KB
testcase_25 AC 516 ms
270,576 KB
testcase_26 AC 522 ms
270,500 KB
testcase_27 AC 525 ms
272,344 KB
testcase_28 AC 515 ms
271,784 KB
testcase_29 AC 511 ms
270,824 KB
testcase_30 AC 518 ms
271,432 KB
testcase_31 AC 517 ms
271,504 KB
testcase_32 AC 516 ms
273,040 KB
testcase_33 AC 519 ms
272,196 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 529 ms
270,552 KB
testcase_39 AC 525 ms
271,140 KB
testcase_40 AC 508 ms
270,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter
from collections import defaultdict, deque
import heapq
import bisect

stdin=sys.stdin
sys.setrecursionlimit(10 ** 8)

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
Yp=lambda:print('Yes')
Np=lambda:print('No')
inf = 1 << 60
eps = 1e-9
sortkey = itemgetter(0)
mod = 10 ** 9 + 7

class Comb():
    def __init__(self, N, mod):
        self.N = N
        self.mod = mod
        self.fa = self.fa_fainv()[0]
        self.fainv = self.fa_fainv()[1]

    def fa_fainv(self):
        fa = [1]
        for i in range(1, self.N + 1):
            fa.append(fa[-1] * i % self.mod)

        fainv = [pow(fa[-1],self.mod - 2,self.mod)]
        for i in range(1, self.N + 1)[::-1]:
            fainv.append(fainv[-1] * i % self.mod)
        fainv = fainv[::-1]

        return fa, fainv

    def calcu_comb(self, a, b):
        if b == 0:
            return 1
        return self.fa[a] * self.fainv[a - b] * self.fainv[b] % self.mod


###############################################################
comb = Comb(2 * 10 ** 6 + 5, mod)

A, B, X, Y = lp()
x = (B + 2) // 2
y = B + 1- x

xp = (x + 1) // 2
xm = x - xp

yp = (y + 1) // 2
ym = y - yp

ans = 0

for i in range(A + 1):
    x_move = i
    y_move = A - i
    if abs(X - x_move) % 2 != 0 or abs(Y - y_move) % 2 != 0 or x_move < abs(X) or y_move < abs(Y):
        continue
    now_xp = (x_move + X) // 2
    now_xm = x_move - now_xp

    now_yp = (y_move + Y) // 2
    now_ym = y_move - now_yp

    if now_xp > 0 and xp <= 0:
        continue
    if now_xm > 0 and xm <= 0:
        continue
    if now_yp > 0 and yp <= 0:
        continue
    if now_ym > 0 and ym < 0:
        continue

    p = comb.calcu_comb(now_xp + xp - 1,xp - 1)
    q = comb.calcu_comb(now_xm + xm - 1,xm - 1)
    r = comb.calcu_comb(now_yp + yp - 1,yp - 1)
    s = comb.calcu_comb(now_ym + ym - 1,ym - 1)
    res = p * q * r * s % mod
    ans += res
    ans %= mod

print(ans)
0