結果
問題 | No.2409 Strange Werewolves |
ユーザー | ruler |
提出日時 | 2023-08-14 15:24:40 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 783 ms / 2,000 ms |
コード長 | 2,332 bytes |
コンパイル時間 | 415 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 134,912 KB |
最終ジャッジ日時 | 2024-11-22 13:44:24 |
合計ジャッジ時間 | 16,127 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 773 ms
134,784 KB |
testcase_01 | AC | 770 ms
134,912 KB |
testcase_02 | AC | 771 ms
134,656 KB |
testcase_03 | AC | 772 ms
134,656 KB |
testcase_04 | AC | 776 ms
134,656 KB |
testcase_05 | AC | 773 ms
134,656 KB |
testcase_06 | AC | 777 ms
134,656 KB |
testcase_07 | AC | 777 ms
134,656 KB |
testcase_08 | AC | 779 ms
134,784 KB |
testcase_09 | AC | 773 ms
134,784 KB |
testcase_10 | AC | 775 ms
134,784 KB |
testcase_11 | AC | 774 ms
134,912 KB |
testcase_12 | AC | 781 ms
134,784 KB |
testcase_13 | AC | 783 ms
134,656 KB |
testcase_14 | AC | 773 ms
134,656 KB |
testcase_15 | AC | 773 ms
134,784 KB |
testcase_16 | AC | 781 ms
134,656 KB |
testcase_17 | AC | 770 ms
134,784 KB |
ソースコード
import sys V = sys.version_info _39 = False _310 = False _311 = False if V.major == 3: _39 = V.minor >= 9 _310 = V.minor >= 10 _311 = V.minor >= 11 if _39: li = list tup = tuple dic = dict st = set ty = type else: from typing import ( List, Tuple, Type, Dict, Set, ) li = List tup = Tuple dic = Dict st = Set ty = Type from sys import stdin read = stdin.buffer.read rl = stdin.buffer.readline rb = lambda: rl().split() rls = stdin.buffer.readlines from typing import Iterable def prints( a: Iterable[object], sep: str = "\n", ) -> None: print(sep.join(map(str, a))) def cumprod(m: int, a: li[int]) -> None: n = len(a) for i in range(1, n): a[i] *= a[i - 1] a[i] %= m def fact(m: int, n: int) -> li[int]: f = list(range(n)) f[0] = 1 cumprod(m, f) return f def tables( m: int, n: int ) -> tup[(li[int],) * 3]: f = fact(m, n) fi = [0] * n iv = [0] * n fi[-1] = pow(f[-1], -1, m) for i in range(1, n)[::-1]: fi[i - 1] = fi[i] * i % m iv[i] = fi[i] * f[i - 1] % m return f, fi, iv class Comb: m: int f: li[int] fi: li[int] inv: li[int] def __init__( self, m: int, n: int ) -> None: self.m = m self.f, self.fi, self.inv = tables( m, n ) def p(self, n: int, k: int) -> int: if k < 0 or n < k: return 0 x = self.f[n] * self.fi[n - k] return x % self.m def c(self, n: int, k: int) -> int: x = self.p(n, k) * self.fi[k] return x % self.m def h(self, n: int, k: int) -> int: return self.c(n - 1 + k, k) def ip(self, n: int, k: int) -> int: assert 0 <= k <= n x = self.fi[n] * self.f[n - k] return x % self.m def ic(self, n: int, k: int) -> int: x = self.ip(n, k) * self.f[k] return x % self.m def solve() -> None: mod = 998_244_353 x, y, z, w = map(int, rb()) f = Comb(mod, 1 << 20) z = max(z, 1) w = max(w, 1) v = f.f[x + y - z - w] v *= f.c(x, z) v %= mod v *= f.c(y, w) v %= mod print(v) def main() -> None: t = 1 # t = int(rl()) for _ in range(t): solve() main()