問題一覧 > 通常問題

No.2409 Strange Werewolves

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 153
作問者 : 👑 AngrySadEight / テスター : 👑 hamamu 👑 qand
お気に入りにしたユーザー ProblemId : 9874 / 自分の提出
問題文最終更新日: 2023-07-31 01:05:31
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 401 (順位表) の他の問題:

Problem Statement

There are $X$ humans and $Y$ wolves, and all humans and wolves are distinguishable from one another. A meeting between the humans and the wolves will now be held.

The meeting proceeds as follows.

  • From among the meeting participants who have not yet been banished, choose $1$ human or $1$ wolf and banish them. Banished humans and wolves can no longer participate in the rest of the meeting.
  • Repeat this until all members of either the humans or the wolves have been banished.
  • The meeting ends as soon as all members of either the humans or the wolves have been banished.

When the meeting ended, $Z$ humans had not yet been banished and $W$ wolves had not yet been banished. Here, one of $Z$ and $W$ is $0$. Find the total number of ways the banishments could have occurred, modulo $998244353$.

Two ways of banishment are considered different if there exists some $i$ such that the human or wolf banished in the $i$-th banishment differs between them.

Constraints

  • All input values are integers.
  • $1 \leq X, Y \leq 3 \times 10^5$
  • $0 \leq Z, W \leq 3 \times 10^5$
  • $Z \leq X$
  • $W \leq Y$
  • $Z = 0$ or $W = 0$
  • $(Z, W) \neq (0, 0)$

Input

The input is given from Standard Input in the following format.

$X$ $Y$ $Z$ $W$

Output

Print the answer.

Sample

Sample 1
Input
2 2 1 0
Output
8

For convenience, label the humans as Humans $1,2$ and the wolves as Wolves $1,2$. Then the following $8$ cases are possible.

  • Banished in the order Human $1$ → Wolf $1$ → Wolf $2$.
  • Banished in the order Human $1$ → Wolf $2$ → Wolf $1$.
  • Banished in the order Human $2$ → Wolf $1$ → Wolf $2$.
  • Banished in the order Human $2$ → Wolf $2$ → Wolf $1$.
  • Banished in the order Wolf $1$ → Human $1$ → Wolf $2$.
  • Banished in the order Wolf $1$ → Human $2$ → Wolf $2$.
  • Banished in the order Wolf $2$ → Human $1$ → Wolf $1$.
  • Banished in the order Wolf $2$ → Human $2$ → Wolf $1$.

Sample 2
Input
2013 8 12 0
Output
212512743

Print the remainder when divided by $998244353$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。