結果

問題 No.1683 Robot Guidance
ユーザー KudeKude
提出日時 2021-09-17 22:08:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,059 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 107,896 KB
最終ジャッジ日時 2023-09-12 07:47:58
合計ジャッジ時間 8,088 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 116 ms
107,352 KB
testcase_02 AC 123 ms
107,364 KB
testcase_03 AC 130 ms
107,548 KB
testcase_04 AC 130 ms
107,752 KB
testcase_05 AC 132 ms
107,552 KB
testcase_06 AC 134 ms
107,568 KB
testcase_07 AC 131 ms
107,660 KB
testcase_08 AC 146 ms
107,620 KB
testcase_09 AC 133 ms
107,552 KB
testcase_10 AC 136 ms
107,736 KB
testcase_11 AC 139 ms
107,700 KB
testcase_12 AC 150 ms
107,708 KB
testcase_13 AC 124 ms
107,420 KB
testcase_14 AC 143 ms
107,608 KB
testcase_15 AC 133 ms
107,620 KB
testcase_16 AC 121 ms
107,304 KB
testcase_17 AC 119 ms
107,304 KB
testcase_18 AC 117 ms
107,308 KB
testcase_19 AC 123 ms
107,500 KB
testcase_20 AC 119 ms
107,604 KB
testcase_21 AC 121 ms
107,896 KB
testcase_22 AC 118 ms
107,320 KB
testcase_23 AC 127 ms
107,420 KB
testcase_24 AC 150 ms
107,648 KB
testcase_25 AC 120 ms
107,364 KB
testcase_26 AC 120 ms
107,452 KB
testcase_27 AC 123 ms
107,360 KB
testcase_28 AC 121 ms
107,500 KB
testcase_29 AC 122 ms
107,492 KB
testcase_30 AC 126 ms
107,476 KB
testcase_31 AC 125 ms
107,420 KB
testcase_32 AC 131 ms
107,496 KB
testcase_33 AC 134 ms
107,716 KB
testcase_34 AC 135 ms
107,692 KB
testcase_35 AC 136 ms
107,712 KB
testcase_36 AC 138 ms
107,752 KB
testcase_37 AC 134 ms
107,776 KB
testcase_38 AC 132 ms
107,612 KB
testcase_39 AC 125 ms
107,580 KB
testcase_40 AC 117 ms
107,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

fact_range = 2 * 10**6 + 100
fact = [1] * (fact_range + 1)
for i in range(0, fact_range):
    fact[i+1] = fact[i] * (i + 1) % MOD

ifact = [1] * (fact_range + 1)
ifact[fact_range] = pow(fact[fact_range], MOD - 2, MOD)
for i in range(fact_range, 0, -1):
    ifact[i-1] = ifact[i] * i % MOD

def comb(n, k):
    if k == 0:
        return 1
    if k < 0 or n < k:
        return 0
    else:
        return fact[n] * ifact[n-k] % MOD * ifact[k] % MOD


g, t, x, y = map(int, input().split())
ans = 0
t += 1
cnt_r = t // 4 + (t % 4 >= 1)
cnt_u = t // 4 + (t % 4 >= 2)
cnt_l = t // 4 + (t % 4 >= 3)
cnt_d = t // 4
for k1 in range(g + 1):
    k2 = g - k1
    if (x + k1) % 2 or (y + k2) % 2 or k1 < abs(x) or k2 < abs(y):
        continue
    x_r = (x + k1) // 2
    x_l = (k1 - x) // 2
    y_u = (y + k2) // 2
    y_d = (k2 - y) // 2
    if k1 == 1:
        print(x_r, x_l, y_u, y_d)
    ans += comb(x_r + cnt_r - 1, x_r) * comb(x_l + cnt_l - 1, x_l) % MOD * comb(y_u + cnt_u - 1, y_u) % MOD * comb(y_d + cnt_d - 1, y_d)
    ans %= MOD
print(ans)
0