CF1237F.Balanced Domino Placements
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Consider a square grid with h rows and w columns with some dominoes on it. Each domino covers exactly two cells of the grid that share a common side. Every cell is covered by at most one domino.
Let's call a placement of dominoes on the grid perfectly balanced if no row and no column contains a pair of cells covered by two different dominoes. In other words, every row and column may contain no covered cells, one covered cell, or two covered cells that belong to the same domino.
You are given a perfectly balanced placement of dominoes on a grid. Find the number of ways to place zero or more extra dominoes on this grid to keep the placement perfectly balanced. Output this number modulo 998244353 .
输入格式
The first line contains three integers h , w , and n ( 1≤h,w≤3600 ; 0≤n≤2400 ), denoting the dimensions of the grid and the number of already placed dominoes. The rows are numbered from 1 to h , and the columns are numbered from 1 to w .
Each of the next n lines contains four integers ri,1,ci,1,ri,2,ci,2 ( 1≤ri,1≤ri,2≤h ; 1≤ci,1≤ci,2≤w ), denoting the row id and the column id of the cells covered by the i -th domino. Cells (ri,1,ci,1) and (ri,2,ci,2) are distinct and share a common side.
The given domino placement is perfectly balanced.
输出格式
Output the number of ways to place zero or more extra dominoes on the grid to keep the placement perfectly balanced, modulo 998244353 .
输入输出样例
输入#1
5 7 2 3 1 3 2 4 4 4 5
输出#1
8
输入#2
5 4 2 1 2 2 2 4 3 4 4
输出#2
1
输入#3
23 42 0
输出#3
102848351
说明/提示
In the first example, the initial grid looks like this:
Here are 8 ways to place zero or more extra dominoes to keep the placement perfectly balanced:
In the second example, the initial grid looks like this:
No extra dominoes can be placed here.