Orig Description
Score : 1100 points
Problem StatementWe have an H \times W grid, where each square is painted white or black in the initial state.
Given are strings A_1, A_2, ..., A_H representing the colors of the squares in the initial state.
For each pair (i, j) (1 \leq i \leq H, 1 \leq j \leq W), if the j-th character of A_i is ., the square at the i-th row and j-th column is painted white; if that character is #, that square is painted black.
Among the 2^{HW} ways for each square in the grid to be painted white or black, how many can be obtained from the initial state by performing the operations below any number of times (possibly zero) in any order? Find this count modulo 998,244,353.
Choose one row, then paint all the squares in that row white.
Choose one row, then paint all the squares in that row black.
Choose one column, then paint all the squares in that column white.
Choose one column, then paint all the squares in that column black.
Constraints
1 \leq H, W \leq 10
|A_i| = W (1 \leq i \leq H)
All strings A_i consist of . and #.
H and W are integers.
InputInput is given from Standard Input in the following format:
H W
A_1
A_2
\vdots
A_H
OutputPrint the answer.
Sample Input 12 2
#.
.#
Sample Output 115
For example, if we paint the second row black, the grid becomes:
#.
##
Sample Input 23 3
...
...
...
Sample Output 2230
Sample Input 32 4
#...
...#
Sample Output 3150
Sample Input 46 7
.......
.......
.#.....
..#....
.#.#...
.......
Sample Output 4203949910
Extracted Specification
Canonicalized Input Description:
An integer H (1 ≤ H ≤ 10), representing some quantity or size.
An integer W (1 ≤ W ≤ 10), representing some quantity or size.
A list of H strings, each of length W, where each character is either '.' or '#'.
### Example Input:
```
2
2
#.
.#
```
### Function Signature:
Write a function f(H, W, A) that takes in the input.
def f(H: int, W: int, A: List[str]):
'''
H: an integer
W: an integer
A: a list of strings
'''
Test Case Generator
Sure, I can help you write a test case generator for the given problem statement. Below is the Python code for the test case generator:
```python
import random
def tcgen():
H = random.randint(1, 10)
W = random.randint(1, 10)
grid = []
for _ in range(H):
row = ''.join(random.choice(['.', '#']) for _ in range(W))
grid.append(row)
return H, W, grid
# Example of generating a test case
H, W, grid = tcgen()
print(H)
print(W)
for row in grid:
print(row)
```
This function generates random test cases based on the constraints provided in the problem statement. Here's how it works:
1. It randomly selects the number of rows \( H \) and columns \( W \) within the range [1, 10].
2. For each row, it creates a string of length \( W \), with each character being either '.' or '#'.
3. It collects these rows into a grid and returns the grid along with values for \( H \) and \( W \).
You can run this function multiple times to generate different test cases for your problem. Here's a quick run example:
```python
# Example of generating a test case
H, W, grid = tcgen()
print(H)
print(W)
for row in grid:
print(row)
```
This will output something like:
```
5
4
.#..
#.#.
.#.#
...#
##.#
```
You can use this generator to create various test cases to thoroughly test your solution.
Extract Arguments
def extract_arguments(fh):
H, W = map(int, fh.readline().strip().split())
A = [fh.readline().strip() for _ in range(H)]
return H, W, A