結果

問題 No.1596 Distance Sum in 2D Plane
ユーザー mkawa2mkawa2
提出日時 2021-07-09 21:53:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,188 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 39,904 KB
最終ジャッジ日時 2023-09-14 08:50:35
合計ジャッジ時間 15,152 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 269 ms
39,904 KB
testcase_02 AC 965 ms
39,380 KB
testcase_03 AC 988 ms
39,508 KB
testcase_04 AC 1,011 ms
39,564 KB
testcase_05 AC 1,003 ms
39,524 KB
testcase_06 AC 972 ms
39,352 KB
testcase_07 AC 994 ms
39,528 KB
testcase_08 AC 1,004 ms
39,352 KB
testcase_09 AC 990 ms
39,384 KB
testcase_10 AC 983 ms
39,444 KB
testcase_11 AC 819 ms
39,728 KB
testcase_12 AC 798 ms
39,828 KB
testcase_13 AC 810 ms
39,828 KB
testcase_14 AC 269 ms
39,704 KB
testcase_15 AC 277 ms
39,760 KB
testcase_16 AC 265 ms
39,752 KB
testcase_17 AC 262 ms
39,716 KB
testcase_18 AC 262 ms
39,848 KB
testcase_19 AC 267 ms
39,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

def nCr(com_n, com_r):
    if com_r < 0: return 0
    if com_n < com_r: return 0
    return fac[com_n]*ifac[com_r]%md*ifac[com_n-com_r]%md

# 準備
n_max = 400005
fac = [1]
for i in range(1, n_max+1): fac.append(fac[-1]*i%md)
ifac = [1]*(n_max+1)
ifac[n_max] = pow(fac[n_max], md-2, md)
for i in range(n_max-1, 1, -1): ifac[i] = ifac[i+1]*(i+1)%md

n, m = LI()
tot = nCr(2*n, n)*2*n
for _ in range(m):
    t, x, y = LI()
    if t == 1:
        tot -= nCr(x+y, x)*nCr(n-x+n-y-1, n-y)%md
    else:
        tot -= nCr(x+y, x)*nCr(n-x+n-y-1, n-y-1)%md
    tot %= md
print(tot)
0