102425: [AtCoder]ABC242 F - Black and White Rooks

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $500$ points

Problem Statement

Consider placing $B$ black rooks and $W$ white rooks on a grid with $N$ horizontal rows and $M$ vertical columns.

A placement of the rooks satisfying all of the following conditions is called a good placement.

  • All $B+W$ rooks are placed on the grid.
  • At most one rook is placed in the same square.
  • There is no pair of white rook and black rook attacking each other. That is, there is no pair of white rook and black rook such that one of them can reach the square in which the other is placed in one move.

Here, in one move, a rook can reach any square that is on a horizontal or vertical line from its current position and is reachable without jumping over another rook.

How many good placements are there? Since this count can be enormous, print it modulo $998244353$.

Rooks in the same color are not distinguished.

Constraints

  • $1 \leq N,M \leq 50$
  • $1 \leq B,W \leq 2500$
  • $B+W \leq N \times M$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $M$ $B$ $W$

Output

Print the count modulo $998244353$.


Sample Input 1

2 2 1 1

Sample Output 1

4

There are four good placements as follows.


Sample Input 2

1 2 1 1

Sample Output 2

0

There may be no good placement.


Sample Input 3

40 40 30 30

Sample Output 3

467620384

Be sure to print the count modulo $998244353$.

Input

题意翻译

考虑在一个 $N$ 行 $M$ 列的棋盘上放置 $B$ 只黑车和 $W$ 只白车。一个好的放置方式应满足以下条件: - 所有车放在方格内。 - 一个方格至多放一只车。 - 没有一对黑车和白车可以互相攻击,即没有一对黑车和白车,它们中的一个可以一步到达另一个所在的方格。 这里,车一步可以到达与之同行或同列的任一方格,前提是不跨过其它棋子。 求好的放置方式的数目。由于答案可能很大,输出对 $998244353$ 取模的结果。 同种颜色的车不区分。 数据范围: - $1 \le N,M \le 50$; - $1 \le B,W \le 2500$; - $B+W \le N \times M$; - 所有输入的数是整数。

Output

分数:500分

问题描述

考虑在一个有$N$行$M$列的网格上放置$B$个黑色的象棋车和$W$个白色的象棋车。

满足以下所有条件的象棋车放置被称为好的放置

  • 所有的$B+W$个象棋车都放置在网格上。
  • 同一个方格中最多放置一个象棋车。
  • 不存在一对白色象棋车和黑色象棋车互相攻击。即不存在一对白色象棋车和黑色象棋车,其中一方可以在一回合内到达另一方所在的方格。

在这里,一回合内,象棋车可以到达与其当前位置在同一水平线或垂直线上的任何方格,且不需要跳过另一个象棋车。

有多少种好的放置方式?由于这个计数可能非常大,因此请打印出它对$998244353$取模的结果。

相同颜色的象棋车没有区别。

约束

  • $1 \leq N,M \leq 50$
  • $1 \leq B,W \leq 2500$
  • $B+W \leq N \times M$
  • 输入中的所有值都是整数。

输入

输入格式如下:

$N$ $M$ $B$ $W$

输出

打印出对$998244353$取模的结果。


样例输入 1

2 2 1 1

样例输出 1

4

有四种好的放置方式,如下所示。


样例输入 2

1 2 1 1

样例输出 2

0

可能不存在好的放置方式。


样例输入 3

40 40 30 30

样例输出 3

467620384

请务必打印出对$998244353$取模的结果。

加入题单

算法标签: