結果

問題 No.1596 Distance Sum in 2D Plane
ユーザー TadaTada
提出日時 2021-07-09 23:35:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 923 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 107,252 KB
最終ジャッジ日時 2023-09-14 10:56:25
合計ジャッジ時間 13,542 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
104,956 KB
testcase_01 AC 100 ms
105,244 KB
testcase_02 AC 923 ms
106,928 KB
testcase_03 AC 910 ms
106,812 KB
testcase_04 AC 908 ms
106,796 KB
testcase_05 AC 910 ms
106,876 KB
testcase_06 AC 900 ms
107,056 KB
testcase_07 AC 905 ms
106,856 KB
testcase_08 AC 917 ms
107,052 KB
testcase_09 AC 919 ms
106,964 KB
testcase_10 AC 910 ms
107,064 KB
testcase_11 AC 838 ms
106,984 KB
testcase_12 AC 852 ms
106,968 KB
testcase_13 AC 836 ms
107,252 KB
testcase_14 AC 72 ms
71,544 KB
testcase_15 AC 73 ms
71,416 KB
testcase_16 AC 70 ms
71,624 KB
testcase_17 AC 70 ms
71,464 KB
testcase_18 AC 73 ms
71,380 KB
testcase_19 AC 72 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

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%mod,

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