CF1254A.Feeding Chicken

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 rr rows and cc columns. Some of these cells contain rice, others are empty. kk 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)(x, y) and (u,v)(u, v) are assigned to the same chicken, this chicken is able to walk from (x,y)(x, y) to (u,v)(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 TT ( 1T21041 \le T \le 2 \cdot 10^4 ). Description of the test cases follows.

The first line of each test case contains three integers rr , cc and kk ( 1r,c100,1k621 \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 rr lines contains cc 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 rcr \cdot c over all test cases does not exceed 21042 \cdot 10^4 .

输出格式

For each test case, print rr lines with cc 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

说明/提示

These pictures explain the sample output. Each color represents one chicken. Cells filled with patterns (not solid colors) contain rice.

In the first test case, each chicken has one cell with rice. Hence, the difference between the maximum and the minimum number of cells with rice assigned to a chicken is 00 .

In the second test case, there are 44 chickens with 33 cells of rice, and 22 chickens with 22 cells of rice. Hence, the difference between the maximum and the minimum number of cells with rice assigned to a chicken is 32=13 - 2 = 1 .

In the third test case, each chicken has 33 cells with rice.

In the last test case, since there are 6262 chicken with exactly 6262 cells of rice, each chicken must be assigned to exactly one cell. The sample output is one of the possible way.

首页