結果
| 問題 |
No.2033 Chromatic Duel
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:36:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,132 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 82,104 KB |
| 実行使用メモリ | 63,032 KB |
| 最終ジャッジ日時 | 2025-06-12 21:39:37 |
| 合計ジャッジ時間 | 2,973 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 8 WA * 29 |
ソースコード
MOD = 998244353
def main():
import sys
input = sys.stdin.read
data = input().strip().split()
N = int(data[0])
B = int(data[1])
W = int(data[2])
if B == 0:
if W == 0:
print(1)
else:
print(0)
return
m = N - W - 2 * B
if m < 1 or m > B:
print(0)
return
# Compute combinatorial numbers using Lucas theorem or precomputed factorials
# Precompute factorial and inverse factorial modulo MOD
max_n = max(N, B, m)
fact = [1] * (max_n + 1)
for i in range(1, max_n + 1):
fact[i] = fact[i-1] * i % MOD
inv_fact = [1] * (max_n + 1)
inv_fact[max_n] = pow(fact[max_n], MOD-2, MOD)
for i in range(max_n-1, -1, -1):
inv_fact[i] = inv_fact[i+1] * (i+1) % MOD
def comb(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
ways_partition = comb(B-1, m-1)
ways_place = comb(N - B - m, m)
total = ways_partition * ways_place % MOD
print(total)
if __name__ == "__main__":
main()
gew1fw