結果
問題 |
No.2033 Chromatic Duel
|
ユーザー |
![]() |
提出日時 | 2025-03-26 15:57:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,501 bytes |
コンパイル時間 | 357 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 86,168 KB |
最終ジャッジ日時 | 2025-03-26 15:57:25 |
合計ジャッジ時間 | 4,647 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 1 WA * 1 TLE * 1 -- * 34 |
ソースコード
MOD = 998244353 def main(): import sys N, B, W = map(int, sys.stdin.readline().split()) max_n = 3 * (10**5) + 10 fact = [1] * (max_n) for i in range(1, max_n): fact[i] = fact[i-1] * i % MOD inv_fact = [1] * (max_n) inv_fact[max_n-1] = pow(fact[max_n-1], MOD-2, MOD) for i in range(max_n-2, -1, -1): inv_fact[i] = inv_fact[i+1] * (i+1) % MOD def C(n, k): if n < 0 or k < 0 or k > n: return 0 return fact[n] * inv_fact[k] % MOD * inv_fact[n - k] % MOD def f(m, s): if s < 0 or s > 2 * m: return 0 res = 0 for k in range(0, m + 1): if 3 * k > s: break term = C(m, k) * C(s - 3 * k + m - 1, m - 1) if k % 2 == 1: term = (-term) % MOD res = (res + term) % MOD return res ans = 0 for K in range(0, B + 2): if K > W: continue if K > 0: if W < K or W - K < 0: continue comb1 = C(B + 1, K) comb2 = C(W - 1, K - 1) else: if W != 0: continue comb1 = C(B + 1, 0) comb2 = 1 s = (N - B - W) - 2 * K m = B + 1 - K if s < 0 or s > 2 * m: continue ways = f(m, s) ans = (ans + comb1 * comb2 % MOD * ways % MOD) % MOD print(ans % MOD) if __name__ == '__main__': main()