結果
問題 | No.2409 Strange Werewolves |
ユーザー | ryohei22 |
提出日時 | 2023-08-11 22:38:00 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 790 bytes |
コンパイル時間 | 194 ms |
コンパイル使用メモリ | 82,380 KB |
実行使用メモリ | 163,680 KB |
最終ジャッジ日時 | 2024-04-29 13:43:35 |
合計ジャッジ時間 | 3,732 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
59,392 KB |
testcase_01 | AC | 58 ms
69,120 KB |
testcase_02 | AC | 35 ms
53,504 KB |
testcase_03 | TLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
ソースコード
from collections import defaultdict MOD = 998244353 X, Y, Z, W = map(int, input().split()) dx = X - Z dy = Y - W # dp[i][j]: i回の会議終了時に人がj人追放されているような組み合わせの数(追放された狼の数は i-j) # 途中で片方が0人になってはいけないことに注意 old = defaultdict(int) old[0] = 1 for i in range(1, dx+dy+1): new = defaultdict(int) for j in old: if (i == dx + dy or X - (j + 1) != 0) and j + 1 <= dx: new[j+1] += old[j] * (X - j) # 人を追放 new[j+1] %= MOD if (i == dx + dy or Y - (i - 1 - j + 1) != 0) and (i - 1 - j) + 1 <= dy: new[j] += old[j] * (Y - (i - 1 - j)) # 狼を追放 new[j] %= MOD old = new print(sum(old.values()) % MOD)