310095: CF1781H2. Window Signals (hard version)

Memory Limit:512 MB Time Limit:7 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Window Signals (hard version)

题目描述

This is the hard version of the problem. In this version, the constraints on $ h $ and $ w $ are higher. A house at the sea has $ h $ floors, all of the same height. The side of the house facing the sea has $ w $ windows at equal distances from each other on every floor. Thus, the windows are positioned in cells of a rectangular grid of size $ h \times w $ . In every window, the light can be turned either on or off, except for the given $ k $ (at most $ 2 $ ) windows. In these $ k $ windows the light can not be turned on, because it is broken. In the dark, we can send a signal to a ship at sea using a configuration of lights turned on and off. However, the ship can not see the position of the lights with respect to the house. Thus, if one configuration can be turned into another using parallel transfer, these configurations are considered equal. Note that only parallel transfer is allowed, but neither rotations nor flips are. Moreover, a configuration without any light at all is not considered valid. Find how many different signals the ship can receive and print this number modulo $ 998\,244\,353 $ .

输入输出格式

输入格式


Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 100 $ ). The description of the test cases follows. The first line of each test case contains three integers $ h $ , $ w $ , and $ k $ ( $ 1 \le h, w \le 200 $ ; $ 0 \le k \le \min(h \cdot w, 2) $ ) — the height of the house, the number of windows on each floor, and the number of windows with broken lights. If $ k > 0 $ , each of the next $ k $ lines contains two integers $ r_i $ and $ c_i $ ( $ 1 \le r_i \le h $ ; $ 1 \le c_i \le w $ ) — the floor number and the window number with the broken light. The floors are numbered $ 1 $ to $ h $ from bottom to top, and the windows are numbered $ 1 $ to $ w $ from left to right. If $ k = 2 $ , then either $ r_1 \ne r_2 $ or $ c_1 \ne c_2 $ . It is guaranteed that the sum of $ h \cdot w $ over all test cases does not exceed $ 40\,000 $ .

输出格式


For each test case, print a single integer — the number of signals the ship can receive, modulo $ 998\,244\,353 $ .

输入输出样例

输入样例 #1

10
1 3 0
2 2 0
3 2 0
4 5 0
12 7 0
1 1 1
1 1
1 3 1
1 2
3 4 1
3 4
2 3 2
1 1
2 1
4 5 2
2 3
4 2

输出样例 #1

4
10
44
954368
34903934
0
2
1696
10
253144

说明

In the first test case, the ship can receive four different signals: all lights on; lights on in two neighboring windows; lights on in the leftmost and the rightmost windows; or light on in any single window.

Input

暂时还没有翻译

Output

**题目大意:**

这个问题是“海边的窗户信号”问题的困难版本。在这个版本中,对 $ h $ 和 $ w $ 的限制更高。

海边有一座 $ h $ 层高的房子,每一层的高度都相同。面向大海的房子侧面,每一层都有 $ w $ 个等距排列的窗户。因此,窗户位于一个 $ h \times w $ 大小的矩形网格的单元格中。

除了给定的 $ k $(最多 $ 2 $ 个)个窗户,因为灯泡坏了,不能打开其余每个窗户的灯。在黑暗中,我们可以通过开启或关闭灯光的配置向海上的船只发送信号。然而,船只无法看到灯光相对于房子的位置。因此,如果可以通过平行移动将一种配置转换为另一种配置,则认为这些配置是相等的。注意,只允许平行移动,不允许旋转或翻转。此外,没有任何灯光的配置被认为是不有效的。

找出船只能接收到多少不同的信号,并模 $ 998\,244\,353 $ 后输出这个数。

**输入输出格式:**

**输入格式:**

每个测试包含多个测试案例。第一行包含测试案例的数量 $ t $($ 1 \le t \le 100 $)。接下来是测试案例的描述。

每个测试案例的第一行包含三个整数 $ h $,$ w $,和 $ k $($ 1 \le h, w \le 200 $;$ 0 \le k \le \min(h \cdot w, 2) $)——房子的高度,每层的窗户数量,以及坏掉的窗户数量。

如果 $ k > 0 $,接下来的 $ k $ 行中的每一行都包含两个整数 $ r_i $ 和 $ c_i $($ 1 \le r_i \le h $;$ 1 \le c_i \le w $)——坏掉的灯所在的楼层号和窗户号。楼层从下到上编号为 $ 1 $ 到 $ h $,窗户从左到右编号为 $ 1 $ 到 $ w $。如果 $ k = 2 $,那么 $ r_1 \ne r_2 $ 或 $ c_1 \ne c_2 $。

保证所有测试案例中 $ h \cdot w $ 的总和不超过 $ 40\,000 $。

**输出格式:**

对于每个测试案例,输出一个整数——船只能接收到的信号数量,模 $ 998\,244\,353 $ 后的结果。

**输入输出样例:**

**输入样例 #1:**
```
10
1 3 0
2 2 0
3 2 0
4 5 0
12 7 0
1 1 1
1 1
1 3 1
1 2
3 4 1
3 4
2 3 2
1 1
2 1
4 5 2
2 3
4 2
```

**输出样例 #1:**
```
4
10
44
954368
34903934
0
2
1696
10
253144
```

**说明:**

在第一个测试案例中,船可以接收到四种不同的信号:所有灯都打开;相邻两个窗户的灯打开;最左边的和最右边的窗户的灯打开;或者任意单个窗户的灯打开。**题目大意:** 这个问题是“海边的窗户信号”问题的困难版本。在这个版本中,对 $ h $ 和 $ w $ 的限制更高。 海边有一座 $ h $ 层高的房子,每一层的高度都相同。面向大海的房子侧面,每一层都有 $ w $ 个等距排列的窗户。因此,窗户位于一个 $ h \times w $ 大小的矩形网格的单元格中。 除了给定的 $ k $(最多 $ 2 $ 个)个窗户,因为灯泡坏了,不能打开其余每个窗户的灯。在黑暗中,我们可以通过开启或关闭灯光的配置向海上的船只发送信号。然而,船只无法看到灯光相对于房子的位置。因此,如果可以通过平行移动将一种配置转换为另一种配置,则认为这些配置是相等的。注意,只允许平行移动,不允许旋转或翻转。此外,没有任何灯光的配置被认为是不有效的。 找出船只能接收到多少不同的信号,并模 $ 998\,244\,353 $ 后输出这个数。 **输入输出格式:** **输入格式:** 每个测试包含多个测试案例。第一行包含测试案例的数量 $ t $($ 1 \le t \le 100 $)。接下来是测试案例的描述。 每个测试案例的第一行包含三个整数 $ h $,$ w $,和 $ k $($ 1 \le h, w \le 200 $;$ 0 \le k \le \min(h \cdot w, 2) $)——房子的高度,每层的窗户数量,以及坏掉的窗户数量。 如果 $ k > 0 $,接下来的 $ k $ 行中的每一行都包含两个整数 $ r_i $ 和 $ c_i $($ 1 \le r_i \le h $;$ 1 \le c_i \le w $)——坏掉的灯所在的楼层号和窗户号。楼层从下到上编号为 $ 1 $ 到 $ h $,窗户从左到右编号为 $ 1 $ 到 $ w $。如果 $ k = 2 $,那么 $ r_1 \ne r_2 $ 或 $ c_1 \ne c_2 $。 保证所有测试案例中 $ h \cdot w $ 的总和不超过 $ 40\,000 $。 **输出格式:** 对于每个测试案例,输出一个整数——船只能接收到的信号数量,模 $ 998\,244\,353 $ 后的结果。 **输入输出样例:** **输入样例 #1:** ``` 10 1 3 0 2 2 0 3 2 0 4 5 0 12 7 0 1 1 1 1 1 1 3 1 1 2 3 4 1 3 4 2 3 2 1 1 2 1 4 5 2 2 3 4 2 ``` **输出样例 #1:** ``` 4 10 44 954368 34903934 0 2 1696 10 253144 ``` **说明:** 在第一个测试案例中,船可以接收到四种不同的信号:所有灯都打开;相邻两个窗户的灯打开;最左边的和最右边的窗户的灯打开;或者任意单个窗户的灯打开。

加入题单

上一题 下一题 算法标签: