結果

問題 No.1596 Distance Sum in 2D Plane
ユーザー mrngmrng
提出日時 2021-12-13 21:35:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 86,764 KB
実行使用メモリ 109,072 KB
最終ジャッジ日時 2023-09-30 03:03:07
合計ジャッジ時間 11,017 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 372 ms
108,008 KB
testcase_01 AC 367 ms
107,932 KB
testcase_02 AC 535 ms
109,000 KB
testcase_03 AC 546 ms
109,004 KB
testcase_04 AC 528 ms
108,744 KB
testcase_05 AC 521 ms
108,944 KB
testcase_06 AC 517 ms
108,848 KB
testcase_07 AC 533 ms
108,960 KB
testcase_08 AC 530 ms
108,884 KB
testcase_09 AC 536 ms
108,792 KB
testcase_10 AC 526 ms
108,888 KB
testcase_11 AC 497 ms
108,964 KB
testcase_12 AC 505 ms
109,072 KB
testcase_13 AC 492 ms
108,792 KB
testcase_14 AC 68 ms
71,296 KB
testcase_15 AC 68 ms
71,300 KB
testcase_16 AC 67 ms
71,332 KB
testcase_17 AC 69 ms
71,296 KB
testcase_18 AC 69 ms
71,244 KB
testcase_19 AC 68 ms
71,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
mod = 10**9+7
f = [i for i in range(2*n+1)]
f[0] = 1
for i in range(2*n):
	f[i+1] *= f[i]
	f[i+1] %= mod
fv = []
for i in range(2*n+1):
	fv.append(pow(f[i],mod-2,mod))
ans = f[2*n]*fv[n]%mod*fv[n]%mod*2*n%mod
for _ in range(m):
	t,x,y = map(int,input().split())
	if t==1:
		ans -= f[x+y]*fv[x]%mod*fv[y]%mod*f[2*n-x-y-1]*fv[n-x-1]%mod*fv[n-y]%mod
		ans %= mod
	else:
		ans -= f[x+y]*fv[x]%mod*fv[y]%mod*f[2*n-x-y-1]*fv[n-x]%mod*fv[n-y-1]%mod
		ans %= mod
print(ans)
0