Orig Description
Score : 300 points
Problem StatementWe have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.
Consider doing the following operation:
Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.
You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
Constraints
1 \leq H, W \leq 6
1 \leq K \leq HW
c_{i,j} is . or #.
InputInput is given from Standard Input in the following format:
H W K
c_{1,1}c_{1,2}...c_{1,W}
c_{2,1}c_{2,2}...c_{2,W}
:
c_{H,1}c_{H,2}...c_{H,W}
OutputPrint an integer representing the number of choices of rows and columns satisfying the condition.
Sample Input 12 3 2
..#
###
Sample Output 15
Five choices below satisfy the condition.
The 1-st row and 1-st column
The 1-st row and 2-nd column
The 1-st row and 3-rd column
The 1-st and 2-nd column
The 3-rd column
Sample Input 22 3 4
..#
###
Sample Output 21
One choice, which is choosing nothing, satisfies the condition.
Sample Input 32 2 3
##
##
Sample Output 30
Sample Input 46 6 8
..##..
.#..#.
#....#
######
#....#
#....#
Sample Output 4208
Extracted Specification
An integer H (1 ≤ H ≤ 6), representing some dimension.
An integer W (1 ≤ W ≤ 6), representing another dimension.
An integer K (1 ≤ K ≤ HW), representing some quantity.
A grid of H rows and W columns, where each cell contains a character from the set {'.', '#'}.
### Example Input:
```
2
3
2
..#
###
```
### Function Signature:
Write a function f(H, W, K, grid) that takes in the input.
def f(H: int, W: int, K: int, grid: List[str]):
'''
H: an integer
W: an integer
K: an integer
grid: a list of strings
'''
Test Case Generator
Certainly! Let's write a test case generator for the given problem statement.
### Problem Statement: Count and Modify
**Description**
You are building a system that processes data based on a character command. The system takes in an array of integers and a character, which specifies a type of operation to perform. Each integer in the array represents a count of operations performed by a device in a network of devices.
**Input**
1. An integer \(N\) (1 ≤ \(N\) ≤ 10^3), representing the number of devices in a network.
2. A list of integers \(A\) of size \(N\), where each integer \(A[i]\) (0 ≤ \(A[i]\) ≤ 10^5) represents the number of operations performed by the \(i\)-th device.
3. A character \(C\) from the set {'a', 'b', 'c', 'd', 'e'}, which determines the type of operation to perform on the array.
**Operations**
- 'a': Increment all the counts by 1.
- 'b': Decrement all the counts by 1 (no count should go below zero).
- 'c': Double the counts of all devices.
- 'd': Halve the counts of all devices (use integer division).
- 'e': Reset all counts to zero.
**Output**
Print the modified list of integers after applying the operation specified by \(C\).
**Examples**
_Input_
```
5
3 10 0 7 15
b
```
_Output_
```
2 9 0 6 14
```
_Input_
```
3
4 5 6
c
```
_Output_
```
8 10 12
```
### Test Case Generator
Here is the test case generator for the given problem statement:
```python
import random
def tcgen():
# Generate random values for H and W within the given constraints
H = random.randint(1, 6)
W = random.randint(1, 6)
# Generate the grid of characters
grid = []
for _ in range(H):
row = ''.join(random.choice(['.', '#']) for _ in range(W))
grid.append(row)
# Generate a random value for K within the given constraints
K = random.randint(1, H * W)
# Print the test case
print(H, W, K)
for row in grid:
print(row)
# Example usage
tcgen()
```
This code generates random values for \(H\) and \(W\) within the specified range (1 to 6), constructs a grid of characters (either '.' or '#'), and chooses a random value for \(K\) within the range from 1 to the total number of cells in the grid (\(H \times W\)). It then prints the generated test case in the required format.
Extract Arguments
def extract_arguments(fh):
H, W, K = map(int, fh.readline().strip().split())
grid = [fh.readline().strip() for _ in range(H)]
return H, W, K, grid