結果
問題 | No.1596 Distance Sum in 2D Plane |
ユーザー | Ain48803949 |
提出日時 | 2021-07-09 22:44:13 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 1,632 ms / 2,000 ms |
コード長 | 1,345 bytes |
コンパイル時間 | 98 ms |
コンパイル使用メモリ | 11,108 KB |
実行使用メモリ | 81,016 KB |
最終ジャッジ日時 | 2023-09-14 10:24:34 |
合計ジャッジ時間 | 23,411 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 793 ms
80,932 KB |
testcase_01 | AC | 793 ms
80,968 KB |
testcase_02 | AC | 1,622 ms
80,984 KB |
testcase_03 | AC | 1,603 ms
80,904 KB |
testcase_04 | AC | 1,632 ms
80,876 KB |
testcase_05 | AC | 1,591 ms
80,892 KB |
testcase_06 | AC | 1,598 ms
80,968 KB |
testcase_07 | AC | 1,603 ms
81,016 KB |
testcase_08 | AC | 1,606 ms
80,852 KB |
testcase_09 | AC | 1,606 ms
80,828 KB |
testcase_10 | AC | 1,599 ms
80,928 KB |
testcase_11 | AC | 1,409 ms
80,820 KB |
testcase_12 | AC | 1,417 ms
80,960 KB |
testcase_13 | AC | 1,392 ms
80,868 KB |
testcase_14 | AC | 34 ms
10,320 KB |
testcase_15 | AC | 34 ms
10,220 KB |
testcase_16 | AC | 34 ms
10,212 KB |
testcase_17 | AC | 34 ms
10,312 KB |
testcase_18 | AC | 34 ms
10,276 KB |
testcase_19 | AC | 35 ms
10,468 KB |
ソースコード
import bisect,collections,copy,heapq,itertools,math,string,sys,queue,time,random input = lambda: sys.stdin.readline().rstrip() def I(): return input() def IS(): return input().split() def II(): return int(input()) def IIS(): return map(int,input().split()) def LIIS(): return list(map(int,input().split())) def Base_n_to_10(X,n): out = 0 for i in range(1,len(str(X))+1): out += int(X[-i])*(n**(i-1)) return out#int out def Base_10_to_n(X, n): if (X//n): return Base_10_to_n(X//n, n)+str(X%n) return str(X%n) INF=10**18 MOD=10**9+7 sys.setrecursionlimit(10**8) ############################################################################## #2nCn N,M=IIS() N*=3 def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n-r] % p p = 10 ** 9 + 7 fact = [1, 1] # fact[n] = (n! mod p) factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) inv = [0, 1] # factinv 計算用 n=N//3 for i in range(2, N + 1): fact.append((fact[-1] * i) % p) inv.append((-inv[p % i] * (p // i)) % p) factinv.append((factinv[-1] * inv[-1]) % p) val=(cmb(n*2,n,p)%p*(n*2))%p for i in range(M): t,x,y=IIS() if t==1: val=(val-(cmb(x+y,x,p)*cmb(2*n-x-y-1,n-y,p)))%p if t==2: val=(val-(cmb(x+y,x,p)*cmb(2*n-x-y-1,n-x,p)))%p print(val)