結果
問題 |
No.1596 Distance Sum in 2D Plane
|
ユーザー |
![]() |
提出日時 | 2025-05-12 06:00:18 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 642 bytes |
コンパイル時間 | 408 ms |
コンパイル使用メモリ | 82,724 KB |
実行使用メモリ | 99,104 KB |
最終ジャッジ日時 | 2025-05-12 06:00:23 |
合計ジャッジ時間 | 4,561 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 RE * 14 |
ソースコード
import sys input = sys.stdin.readline mod=10**9+7 FACT=[1] for i in range(1,2*10**5+1): FACT.append(FACT[-1]*i%mod) FACT_INV=[pow(FACT[-1],mod-2,mod)] for i in range(2*10**5,0,-1): FACT_INV.append(FACT_INV[-1]*i%mod) FACT_INV.reverse() def Combi(a,b): if 0<=b<=a: return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod else: return 0 N,M=map(int,input().split()) ANS=Combi(N+N,N)*N*2 for i in range(M): t,x,y=map(int,input().split()) if t==1: ANS-=Combi(x+y,x)*Combi((N-x-1)+(N-y),N-x-1)%mod else: ANS-=Combi(x+y,x)*Combi((N-x)+(N-y-1),N-y-1)%mod ANS%=mod print(ANS%mod)