CF1781H1.Window Signals (easy version)

NOI/NOI+/CTSC

通过率:0%

时间限制:7.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is the easy version of the problem. In this version, the constraints on hh and ww are lower.

A house at the sea has hh floors, all of the same height. The side of the house facing the sea has ww windows at equal distances from each other on every floor. Thus, the windows are positioned in cells of a rectangular grid of size h×wh \times w.

In every window, the light can be turned either on or off, except for the given kk (at most 22) windows. In these kk 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 of windows with lights on can be transformed into another using parallel translation, these configurations are considered equal. Note that only parallel translation 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 353998\,244\,353.

这是该问题的简单版本。在此版本中,hh 和 ww 的约束更小。

一座海边的房子共有 hh 层,每层高度相同。面向大海的一侧,每层均有 ww 扇窗户,且同一层上的窗户彼此间距相等。因此,所有窗户位于一个 h×wh \times w 大小的矩形网格的格点上。

每扇窗户中的灯均可开启或关闭,但给定的 kk(最多为 22)扇窗户除外:这些窗户的灯已损坏,无法开启。

在黑暗中,我们可通过控制各窗户灯的亮灭状态向海上的船只发送信号。然而,船只无法识别灯光相对于房屋的位置。因此,若一种亮灯配置可通过平移变换得到另一种亮灯配置,则这两种配置被视为等价。注意:仅允许平移变换,不允许旋转或翻转。此外,没有任何一盏灯亮起的配置不被视为有效信号。

请计算船只可接收到的不同信号数量,并将结果对 998 244 353998\,244\,353 取模后输出。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1001 \le t \le 100). The description of the test cases follows.

The first line of each test case contains three integers hh, ww, and kk (1≤h,w≤401 \le h, w \le 40; 0≤k≤min⁡(h⋅w,2)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>0k \gt 0, each of the next kk lines contains two integers rir_i and cic_i (1≤ri≤h1 \le r_i \le h; 1≤ci≤w1 \le c_i \le w) — the floor number and the window number with the broken light. The floors are numbered 11 to hh from bottom to top, and the windows are numbered 11 to ww from left to right. If k=2k = 2, then either r1≠r2r_1 \ne r_2 or c1≠c2c_1 \ne c_2.

It is guaranteed that the sum of h⋅wh \cdot w over all test cases does not exceed 16001600.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1001 \le t \le 100)。随后是各测试用例的描述。

每个测试用例的第一行包含三个整数 hh、ww 和 kk(1≤h,w≤401 \le h, w \le 40;0≤k≤min⁡(h⋅w,2)0 \le k \le \min(h \cdot w, 2)),分别表示房屋的高度、每层楼的窗户数量以及灯损坏的窗户数量。

若 k>0k > 0,则接下来的 kk 行中,每行包含两个整数 rir_i 和 cic_i(1≤ri≤h1 \le r_i \le h;1≤ci≤w1 \le c_i \le w),表示灯损坏的窗户所在的楼层编号和窗户编号。楼层编号从底到顶为 11 至 hh,窗户编号从左到右为 11 至 ww。若 k=2k = 2,则满足 r1≠r2r_1 \ne r_2 或 c1≠c2c_1 \ne c_2。

保证所有测试用例的 h⋅wh \cdot w 之和不超过 16001600。

输出格式

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

对于每个测试用例,输出一个整数——飞船能够接收到的信号数量对 998 244 353998\,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.

在第一个测试用例中,飞船可以接收到四种不同的信号:所有灯均亮起;两个相邻窗口的灯亮起;最左侧和最右侧窗口的灯亮起;或任意单个窗口的灯亮起。

输入解题思路,AI测评打分。不知道怎么写?

首页