#P9359. [ICPC2022 Xi'an R] Cells Coloring

[ICPC2022 Xi'an R] Cells Coloring

题目描述

You are given an n×mn \times m grid. Some of the cells are obstacles, the others are empty. Choose a non-negative integer kk and color all empty cells with k+1k+1 colors 0,1,2,k0, 1, 2, \ldots k. You can not color two cells in the same row or same column with the same non-zero color.

You are given two non-negative integers cc and dd. For a coloring plan, define zz as the number of the cells with color 00. Define the cost of the plan is ck+dzck+dz.

Find the minimum cost.

输入格式

The first line contains four integers nn, mm (1n,m2501\leq n, m\leq 250), cc and dd (0c,d1090\leq c, d\leq 10 ^ 9).

The ii-th line of the next nn lines contains a string of mm characters. The jj-th character is * if the cell in the ii-th row and the jj-th column is an obstacle. The jj-th character is . if the cell in the ii-th row and the jj-th column is empty.

输出格式

Output a line with a single number, representing the answer.

题目大意

题目描述

给定一个 n×mn\times m 的网格。一些格子是障碍,其它格子是空的。选择一个非负整数 kk,并用 k+1k + 1 种颜色 0,1,,k0, 1, \ldots, k 给空格子染色。不能有同一行或同一列的两个格子被染成了相同的 非零 颜色。

给定两个非负整数 c,dc, d。对于一组染色方案,定义 zz 表示染成颜色 00 的格子数量,则该方案的代价为 ck+dzck + dz

求出最小代价。

1n,m2501\leq n, m \leq 2500c,d1090\leq c, d\leq 10 ^ 9

输入格式

第一行四个整数 n,m,c,dn, m, c, d

接下来 nn 行,每行一个长度为 mm 的字符串。字符串的第 jj 个字符为 * 表示第 ii 行第 jj 列的格子为障碍,为 . 表示为空。

输出格式

输出一行一个整数表示答案。

3 4 2 1
.***
*..*
**..

4

3 4 1 2
.***
*..*
**..

2

提示

Source: The 2022 ICPC Asia Xi'an Regional Contest Problem B.

Author: csy2005.