問題一覧 > 通常問題

No.1662 (ox) Alternative

レベル : / AI推定難易度 : 2600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 40
作問者 : 👑 箱星 / テスター : LayCurse ygussany
お気に入りにしたユーザー ProblemId : 6750 / 自分の提出
問題文最終更新日: 2022-04-26 00:13:12
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 311 (順位表) の他の問題:

Problem Statement

Among the strings of length $A+B+C+D$ consisting of $A$ copies of (, $B$ copies of ), $C$ copies of o, and $D$ copies of x, find the number of those satisfying the following condition, modulo $10^9+7$.

  • The string obtained by replacing every occurrence of o with () and every occurrence of x with )( is a balanced parenthesis string.

Answer for $T$ test cases.

▼ (Definition of a balanced parenthesis string)

A balanced parenthesis string is a string satisfying one of the following conditions.

  • It is the empty string.
  • There exist non-empty balanced parenthesis strings $s,t$, and it is the string obtained by concatenating $s,t$ in this order.
  • There exists a balanced parenthesis string $s$, and it is the string obtained by concatenating (, $s$, ) in this order.

Constraints

  • $1\le T\le 10^5$
  • $0\le A,B,C,D\le 10^5$
  • $A+B+C+D\ge 1$
  • All input values are integers.

Input

$T$
$\text{case}_1$
$\text{case}_2$
$\vdots$
$\text{case}_T$

Each test case is given in the following format.

$A$ $B$ $C$ $D$

Output

Output $T$ lines. On the $i$-th line, output the answer for the $i$-th test case.

Sample

Sample 1
Input
3
1 1 1 1
31 41 59 26
999 999 0 1234
Output
4
0
479533106

(Test case $1$) There are $4$ such strings: (ox), (xo), o(x), (x)o.

(Test case $2$) There is not even $1$ such string.

(Test case $3$) Output the remainder when divided by $10^9+7$.

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