CF1672G.Cross Xor

NOI/NOI+/CTSC

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There is a grid with rr rows and cc columns, where the square on the ii-th row and jj-th column has an integer ai,ja_{i, j} written on it. Initially, all elements are set to 00. We are allowed to do the following operation:

  • Choose indices 1≤i≤r1 \le i \le r and 1≤j≤c1 \le j \le c, then replace all values on the same row or column as (i,j)(i, j) with the value xor 11. In other words, for all ax,ya_{x, y} where x=ix=i or y=jy=j or both, replace ax,ya_{x, y} with ax,ya_{x, y} xor 11.

You want to form grid bb by doing the above operations a finite number of times. However, some elements of bb are missing and are replaced with '?' instead.

Let kk be the number of '?' characters. Among all the 2k2^k ways of filling up the grid bb 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 00. As this number can be large, output it modulo 998244353998244353.

有一个 rr 行 cc 列的网格,其中第 ii 行第 jj 列的方格上写有一个整数 ai,ja_{i, j}。初始时,所有元素均为 00。我们允许执行以下操作:

  • 选择下标 1≤i≤r1 \le i \le r 和 1≤j≤c1 \le j \le c,然后将所有与位置 (i,j)(i, j) 处于同一行或同一列的元素的值异或 11。换言之,对所有满足 x=ix=i 或 y=jy=j(或两者同时成立)的 ax,ya_{x, y},将其替换为 ax,y⊕1a_{x, y} \oplus 1。

你希望通过对上述操作执行有限次,得到目标网格 bb。然而,bb 中部分元素缺失,被替换为字符 '?'。

设 kk 为 '?' 字符的个数。在所有 2k2^k 种将每个 '?' 替换为 '0' 或 '1' 的填充方式中,统计有多少种填充后的网格 bb 可以通过从全零网格出发、执行上述操作有限次而得到。由于答案可能很大,请输出其对 998244353998244353 取模的结果。

输入格式

The first line contains two integers rr and cc (1≤r,c≤20001 \le r, c \le 2000) — the number of rows and columns of the grid respectively.

The ii-th of the next rr lines contain cc characters bi,1,bi,2,…,bi,cb_{i, 1}, b_{i, 2}, \ldots, b_{i, c} (bi,j∈0,1,?b_{i, j} \in {0, 1, ?}).

第一行包含两个整数 rr 和 cc(1≤r,c≤20001 \le r, c \le 2000),分别表示网格的行数和列数。

接下来的 rr 行中,第 ii 行包含 cc 个字符 bi,1,bi,2,…,bi,cb_{i, 1}, b_{i, 2}, \ldots, b_{i, c}(其中 bi,j∈{0,1,?}b_{i, j} \in \{0, 1, ?\})。

输出格式

Print a single integer representing the number of ways to fill up grid bb modulo 998244353998244353.

输出一个整数,表示填充网格 bb 的方案数对 998244353998244353 取模的结果。

输入输出样例

  • 输入#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:

0

1

0

1

1

1

0

1

0

This can be accomplished by doing a single operation by choosing (i,j)=(2,2)(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.

在第一个测试用例中,填充 ?\texttt{?} 的唯一方式如下所示:

0

1

0

1

1

1

0

1

0

这可以通过执行一次操作实现,即选择 (i,j)=(2,2)(i,j)=(2,2)。

在第二个测试用例中,可以证明不存在任何操作序列能够生成该网格。

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

首页