結果

問題 No.1596 Distance Sum in 2D Plane
ユーザー TadaTada
提出日時 2021-07-09 22:51:42
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 390 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 844,156 KB
最終ジャッジ日時 2023-09-14 10:28:29
合計ジャッジ時間 5,634 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())

mod=10**9+7
fac=[1]

for i in range(1,N*2+1):
    fac+=fac[-1]*i,

def comb(n,k):
    return fac[n]*pow(fac[k],mod-2,mod)*pow(fac[n-k],mod-2,mod)%mod

ans=comb(2*N,N)*N*2
for i 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-x-1)
    if t==2:
        ans-=comb(x+y,y)*comb(2*N-x-y-1,N-y-1)

print(ans%mod)
0