結果

問題 No.1596 Distance Sum in 2D Plane
ユーザー hir355hir355
提出日時 2021-07-09 21:50:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 916 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 82,464 KB
最終ジャッジ日時 2023-09-14 08:36:49
合計ジャッジ時間 13,089 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
78,920 KB
testcase_01 AC 85 ms
78,848 KB
testcase_02 AC 914 ms
82,268 KB
testcase_03 AC 898 ms
82,272 KB
testcase_04 AC 900 ms
82,156 KB
testcase_05 AC 890 ms
81,876 KB
testcase_06 AC 892 ms
81,948 KB
testcase_07 AC 896 ms
82,056 KB
testcase_08 AC 885 ms
81,984 KB
testcase_09 AC 883 ms
82,092 KB
testcase_10 AC 916 ms
82,192 KB
testcase_11 AC 827 ms
82,464 KB
testcase_12 AC 829 ms
82,256 KB
testcase_13 AC 824 ms
82,216 KB
testcase_14 AC 77 ms
71,452 KB
testcase_15 AC 76 ms
71,116 KB
testcase_16 AC 76 ms
71,484 KB
testcase_17 AC 77 ms
71,276 KB
testcase_18 AC 76 ms
71,508 KB
testcase_19 AC 78 ms
71,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
n, m = map(int, input().split())
fac = [1] * (n * 2 + 1)
for i in range(len(fac) - 1):
    fac[i + 1] = fac[i] * (i + 1) % MOD
comb = lambda n, r : fac[n] * pow(fac[n - r], MOD - 2, MOD) * pow(fac[r], MOD - 2, MOD) % MOD
ans = comb(2 * n, n) * n * 2
for _ in range(m):
    t, x, y = map(int, input().split())
    if t == 1:
        ans -= comb(x + y, x) * comb(n * 2 - x - y - 1, n - y)
    else:
        ans -= comb(x + y, x) * comb(n * 2 - x - y - 1, n - x)
print(ans % MOD)
0