A15754 | Window Signals (easy version)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
This is the easy version of the problem. In this version, the constraints on $h$ and $w$ are lower.
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$ .
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 40$ ; $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 $1600$ .
The first line of each test case contains three integers $h$ , $w$ , and $k$ ( $1 \le h, w \le 40$ ; $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 $1600$ .
输出格式
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted