#15569. [ICPC 2022 Xi'an R] Cells Coloring

    ID: 15569 传统题 1000ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P93592022三分网络流O2优化二分图ICPC西安

[ICPC 2022 Xi'an R] Cells Coloring

[ICPC 2022 Xi'an R] Cells Coloring

题目描述

You are given an $n \times m$ grid. Some of the cells are obstacles, the others are empty. Choose a non-negative integer $k$ and color all empty cells with $k+1$ colors $0, 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 $n$, $m$ ($1\leq n, m\leq 250$), $c$ and $d$ ($0\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.
3 4 2 1
.***
*..*
**..
4
3 4 1 2
.***
*..*
**..
2

提示

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

Author: csy2005. 标签: P9359|2022|三分|网络流|O2优化|二分图|ICPC|西安

来源

P9359|[ICPC 2022 Xi'an R] Cells Coloring