A14995 | Cross Xor
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There is a grid with $r$ rows and $c$ columns, where the square on the $i$ -th row and $j$ -th column has an integer $a_{i, j}$ written on it. Initially, all elements are set to $0$ . We are allowed to do the following operation:
- Choose indices $1 \le i \le r$ and $1 \le j \le c$ , then replace all values on the same row or column as $(i, j)$ with the value xor $1$ . In other words, for all $a_{x, y}$ where $x=i$ or $y=j$ or both, replace $a_{x, y}$ with $a_{x, y}$ xor $1$ .
You want to form grid $b$ by doing the above operations a finite number of times. However, some elements of $b$ are missing and are replaced with '?' instead.
Let $k$ be the number of '?' characters. Among all the $2^k$ ways of filling up the grid $b$ by replacing each '?' with '0' or '1', count the number of grids, that can be formed by doing the above operation a finite number of times, starting from the grid filled with $0$ . As this number can be large, output it modulo $998244353$ .
- Choose indices $1 \le i \le r$ and $1 \le j \le c$ , then replace all values on the same row or column as $(i, j)$ with the value xor $1$ . In other words, for all $a_{x, y}$ where $x=i$ or $y=j$ or both, replace $a_{x, y}$ with $a_{x, y}$ xor $1$ .
You want to form grid $b$ by doing the above operations a finite number of times. However, some elements of $b$ are missing and are replaced with '?' instead.
Let $k$ be the number of '?' characters. Among all the $2^k$ ways of filling up the grid $b$ by replacing each '?' with '0' or '1', count the number of grids, that can be formed by doing the above operation a finite number of times, starting from the grid filled with $0$ . As this number can be large, output it modulo $998244353$ .
输入格式
The first line contains two integers $r$ and $c$ ( $1 \le r, c \le 2000$ ) — the number of rows and columns of the grid respectively.
The $i$ -th of the next $r$ lines contain $c$ characters $b_{i, 1}, b_{i, 2}, \ldots, b_{i, c}$ ( $b_{i, j} \in \{0, 1, ?\}$ ).
The $i$ -th of the next $r$ lines contain $c$ characters $b_{i, 1}, b_{i, 2}, \ldots, b_{i, c}$ ( $b_{i, j} \in \{0, 1, ?\}$ ).
输出格式
Print a single integer representing the number of ways to fill up grid $b$ modulo $998244353$ .
输入输出样例
输入 #1
3 3 ?10 1?? 010
输出 #1
1
输入 #2
2 3 000 001
输出 #2
0
输入 #3
1 1 ?
输出 #3
2
输入 #4
6 9 1101011?0 001101?00 101000110 001011010 0101?01?? 00?1000?0
输出 #4
8
In the first test case, the only way to fill in the $\texttt{?}$ s is to fill it in as such:
010111010This can be accomplished by doing a single operation by choosing $(i,j)=(2,2)$ .
In the second test case, it can be shown that there is no sequence of operations that can produce that grid.
010111010This can be accomplished by doing a single operation by choosing $(i,j)=(2,2)$ .
In the second test case, it can be shown that there is no sequence of operations that can produce that grid.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted