結果

問題 No.1596 Distance Sum in 2D Plane
ユーザー Tada
提出日時 2021-07-09 22:51:42
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 390 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 850,020 KB
最終ジャッジ日時 2024-07-01 18:00:42
合計ジャッジ時間 4,319 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other MLE * 1 -- * 16
権限があれば一括ダウンロードができます

ソースコード

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