306808: CF1254A. Feeding Chicken
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Feeding Chicken
题意翻译
对于每个测试点,共有$T$组数据。对于每组数据: 给定$r$行$c$列字符矩阵,每个元素为'.'或者'r'。 给定正整数$k$,现将要字符矩阵划分为四连通的$k$块,并定义每个连通块的权值为其中'r'的个数。 试求一种划分方案,使得连通块之间的最大权值减最小权值之差最小。 划分方案将用字符集$\{\textrm{`0',`1',\dots,`9',`a',`b',\dots,`z',`A',`B',\dots,`Z'}\}$来表示:两个位置属于同一连通块,当且仅当它们对应的字符相同。 如果有多种方案,任意输出一种即可。 $T\le 2\times 10^4, r\le 100,c\le 100,k\le 62$,且 单个测试点中的$r\times c$总和不超过$2\times 10^4$。 _Translated by Caro23333_题目描述
Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm. His farm is presented by a rectangle grid with $ r $ rows and $ c $ columns. Some of these cells contain rice, others are empty. $ k $ chickens are living on his farm. The number of chickens is not greater than the number of cells with rice on the farm. Long wants to give his chicken playgrounds by assigning these farm cells to his chickens. He would like to satisfy the following requirements: - Each cell of the farm is assigned to exactly one chicken. - Each chicken is assigned at least one cell. - The set of cells assigned to every chicken forms a connected area. More precisely, if two cells $ (x, y) $ and $ (u, v) $ are assigned to the same chicken, this chicken is able to walk from $ (x, y) $ to $ (u, v) $ by passing only its cells and moving from each cell to another cell sharing a side. Long also wants to prevent his chickens from fighting for food. Hence he wants the difference between the maximum and the minimum number of cells with rice assigned to a chicken to be as small as possible. Please help him.输入输出格式
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $ T $ ( $ 1 \le T \le 2 \cdot 10^4 $ ). Description of the test cases follows. The first line of each test case contains three integers $ r $ , $ c $ and $ k $ ( $ 1 \leq r, c \leq 100, 1 \leq k \leq 62 $ ), representing the size of Long's farm and the number of chickens Long has. Each of the next $ r $ lines contains $ c $ characters, each is either "." or "R", representing an empty cell or a cell with rice. It is guaranteed that the number of chickens is not greater than the number of cells with rice on the farm. It is guaranteed that the sum of $ r \cdot c $ over all test cases does not exceed $ 2 \cdot 10^4 $ .
输出格式
For each test case, print $ r $ lines with $ c $ characters on each line. Each character should be either a lowercase English character, an uppercase English character, or a digit. Two characters should be equal if and only if the two corresponding cells are assigned to the same chicken. Uppercase and lowercase characters are considered different, so "A" and "a" belong to two different chickens. If there are multiple optimal answers, print any.
输入输出样例
输入样例 #1
4
3 5 3
..R..
...R.
....R
6 4 6
R..R
R..R
RRRR
RRRR
R..R
R..R
5 5 4
RRR..
R.R..
RRR..
R..R.
R...R
2 31 62
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
输出样例 #1
11122
22223
33333
aacc
aBBc
aBBc
CbbA
CbbA
CCAA
11114
22244
32444
33344
33334
abcdefghijklmnopqrstuvwxyzABCDE
FGHIJKLMNOPQRSTUVWXYZ0123456789