結果

問題 No.1596 Distance Sum in 2D Plane
ユーザー Eki1009Eki1009
提出日時 2021-07-09 21:44:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,388 KB
実行使用メモリ 93,576 KB
最終ジャッジ日時 2023-09-14 08:20:02
合計ジャッジ時間 5,634 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
91,372 KB
testcase_01 AC 96 ms
91,364 KB
testcase_02 AC 255 ms
93,096 KB
testcase_03 AC 262 ms
93,288 KB
testcase_04 AC 260 ms
93,104 KB
testcase_05 AC 250 ms
93,020 KB
testcase_06 AC 248 ms
92,824 KB
testcase_07 AC 253 ms
92,888 KB
testcase_08 AC 246 ms
92,876 KB
testcase_09 AC 249 ms
92,976 KB
testcase_10 AC 250 ms
93,096 KB
testcase_11 AC 222 ms
93,576 KB
testcase_12 AC 219 ms
93,384 KB
testcase_13 AC 219 ms
93,388 KB
testcase_14 AC 96 ms
91,360 KB
testcase_15 AC 96 ms
91,396 KB
testcase_16 AC 97 ms
91,600 KB
testcase_17 AC 98 ms
91,372 KB
testcase_18 AC 94 ms
91,556 KB
testcase_19 AC 96 ms
91,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9+7
n, m = map(int, input().split())
u = 10**6
ans = 0
F = [1]*(u+1)
for i in range(u):
    F[i+1] = F[i]*(i+1)%mod
I = [1]*(u+1)
I[u] = pow(F[u], mod-2, mod)
for i in range(u)[::-1]:
    I[i] = I[i+1]*(i+1)%mod
def comb(n, k):
    if 0 <= k <= n:
        return F[n] * I[k] % mod * I[n-k] % mod
    return 0
ans = comb(2*n, n) * 2 * n
ans %= mod
for _ in range(m):
    t, x, y = map(int, input().split())
    if t == 1:
        ans -= comb(x+y, x) * comb(2*n-(x+y+1), n-y)
    else:
        ans -= comb(x+y, x) * comb(2*n-(x+y+1), n-x)
    ans %= mod
print(ans)
0