#abc295h. Ex - E or m
Ex - E or m
Score : points
问题描述
我们有一个 行和 列的网格 。最初,每个格子上都写有数字 。
- 对于满足 的每个整数 ,在第 行中,将左侧零个或多个格子中的数字变为 。
- 对于满足 的每个整数 ,在第 列中,将顶部零个或多个格子中的数字变为 。
令 为通过上述方式可以获得的所有网格集合。
给定一个由 0
、1
和 ?
组成的 行和 列的网格 。
其中包含 个 ?
,通过将每个 ?
替换为 0
或 1
,可以得到 个不同的网格。请问,在这些网格中有多少个属于集合 ?
由于这个计数可能非常大,请计算它对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a grid with rows and columns. Initially, is written on every square.
Let us perform the following operation.
- For each integer such that , in the -th row, turn the digits in zero or more leftmost squares into .
- For each integer such that , in the -th column, turn the digits in zero or more topmost squares into .
Let be the set of grids that can be obtained in this way.
You are given a grid with rows and columns consisting of 0
, 1
, and ?
.
There are grids that can be obtained by replacing each ?
with 0
or 1
, where is the number of ?
in . How many of them are in ?
This count can be enormous, so find it modulo .
Constraints
- and are integers.
- is a grid with rows and columns consisting of
0
,1
, and?
.
Input
The input is given from Standard Input in the following format:
Output
Print an integer representing the answer.
Sample Input 1
2 3
0?1
?1?
Sample Output 1
6
The following six grids are in .
011 011 001
010 011 110
001 011 011
111 110 111
Sample Input 2
5 3
101
010
101
010
101
Sample Output 2
0
may have no ?
, and the answer may be .
Sample Input 3
18 18
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
??????????????????
Sample Output 3
462237431
Be sure to find the count modulo .
update @ 2024/3/10 12:17:21