結果
問題 | No.1596 Distance Sum in 2D Plane |
ユーザー | mkawa2 |
提出日時 | 2021-07-09 22:57:53 |
言語 | PyPy3 (7.3.13) |
結果 |
AC
|
実行時間 | 240 ms / 2,000 ms |
コード長 | 1,193 bytes |
コンパイル時間 | 463 ms |
コンパイル使用メモリ | 87,164 KB |
実行使用メモリ | 109,576 KB |
最終ジャッジ日時 | 2023-09-14 10:30:21 |
合計ジャッジ時間 | 5,477 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 104 ms
108,504 KB |
testcase_01 | AC | 105 ms
108,416 KB |
testcase_02 | AC | 240 ms
109,576 KB |
testcase_03 | AC | 236 ms
109,524 KB |
testcase_04 | AC | 233 ms
109,368 KB |
testcase_05 | AC | 227 ms
109,392 KB |
testcase_06 | AC | 233 ms
109,284 KB |
testcase_07 | AC | 230 ms
109,468 KB |
testcase_08 | AC | 224 ms
109,288 KB |
testcase_09 | AC | 224 ms
109,516 KB |
testcase_10 | AC | 225 ms
109,116 KB |
testcase_11 | AC | 195 ms
109,488 KB |
testcase_12 | AC | 194 ms
109,460 KB |
testcase_13 | AC | 191 ms
109,396 KB |
testcase_14 | AC | 105 ms
108,496 KB |
testcase_15 | AC | 104 ms
108,592 KB |
testcase_16 | AC | 106 ms
108,420 KB |
testcase_17 | AC | 106 ms
108,384 KB |
testcase_18 | AC | 107 ms
108,428 KB |
testcase_19 | AC | 104 ms
108,536 KB |
ソースコード
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%md 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)