307461: CF1359B. New Theatre Square
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
New Theatre Square
题意翻译
给一个 $n\times m$ 的网格,其中为 `.` 的格子是白色的,为 `*` 的格子是黑色的。 你有两种瓷砖,一种是 $1\times 1$ 的,每块需要 $x$ 元;另一种是 $1\times 2$ 的,每块需要 $y$ 元。 求铺满所有白色格子的最小花费。注意黑色格子上**不能**铺瓷砖。题目描述
You might have remembered Theatre square from the [problem 1A](https://codeforces.com/problemset/problem/1/A). Now it's finally getting repaved. The square still has a rectangular shape of $ n \times m $ meters. However, the picture is about to get more complicated now. Let $ a_{i,j} $ be the $ j $ -th square in the $ i $ -th row of the pavement. You are given the picture of the squares: - if $ a_{i,j} = $ "\*", then the $ j $ -th square in the $ i $ -th row should be black; - if $ a_{i,j} = $ ".", then the $ j $ -th square in the $ i $ -th row should be white. The black squares are paved already. You have to pave the white squares. There are two options for pavement tiles: - $ 1 \times 1 $ tiles — each tile costs $ x $ burles and covers exactly $ 1 $ square; - $ 1 \times 2 $ tiles — each tile costs $ y $ burles and covers exactly $ 2 $ adjacent squares of the same row. Note that you are not allowed to rotate these tiles or cut them into $ 1 \times 1 $ tiles. You should cover all the white squares, no two tiles should overlap and no black squares should be covered by tiles. What is the smallest total price of the tiles needed to cover all the white squares?输入输出格式
输入格式
The first line contains a single integer $ t $ ( $ 1 \le t \le 500 $ ) — the number of testcases. Then the description of $ t $ testcases follow. The first line of each testcase contains four integers $ n $ , $ m $ , $ x $ and $ y $ ( $ 1 \le n \le 100 $ ; $ 1 \le m \le 1000 $ ; $ 1 \le x, y \le 1000 $ ) — the size of the Theatre square, the price of the $ 1 \times 1 $ tile and the price of the $ 1 \times 2 $ tile. Each of the next $ n $ lines contains $ m $ characters. The $ j $ -th character in the $ i $ -th line is $ a_{i,j} $ . If $ a_{i,j} = $ "\*", then the $ j $ -th square in the $ i $ -th row should be black, and if $ a_{i,j} = $ ".", then the $ j $ -th square in the $ i $ -th row should be white. It's guaranteed that the sum of $ n \times m $ over all testcases doesn't exceed $ 10^5 $ .
输出格式
For each testcase print a single integer — the smallest total price of the tiles needed to cover all the white squares in burles.
输入输出样例
输入样例 #1
4
1 1 10 1
.
1 2 10 1
..
2 1 10 1
.
.
3 3 3 7
..*
*..
.*.
输出样例 #1
10
1
20
18