22665_Addaqueen

2022-5-16 18:22| 发布者: Hocassian| 查看: 35| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506834659400-Problem List-采集的数据-后羿采集器.html

Pro.ID

22665

Title

Add a queen

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22665

AC

1

Submit

7

Ratio

14.29%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    K chess queens (0 ≤ K < M×N ) are located on a rectangular chessboard of size M × N ( 1 ≤ M , N ≤ 26 ) and there is no more than one queen in each cell. We consider a vacant cell is under attack if it's possible to move into it at least one of the queens with just one move according to the chess rules.

    The task is to add one more queen into one of the vacant chessboard cells so that the number of cells under action will be minimal .

    The chessboard rows are labeled with lowercase Latin letters starting with a from the bottom; the columns are labeled with numbers starting with 1 from the left. Thus the cells can be labeled as a1, f23, etc.

    输入

    Input  consists of K + 1 lines: the first line contains the values M, N and K separated by one or several spaces; the next lines contain the labels of the cells where the queens are placed initially (one label per line).

    输出

    Description

    K chess queens (0 ≤ K < M×N ) are located on a rectangular chessboard of size M × N ( 1 ≤ M , N ≤ 26 ) and there is no more than one queen in each cell. We consider a vacant cell is under attack if it's possible to move into it at least one of the queens with just one move according to the chess rules.

    The task is to add one more queen into one of the vacant chessboard cells so that the number of cells under action will be minimal .

    The chessboard rows are labeled with lowercase Latin letters starting with a from the bottom; the columns are labeled with numbers starting with 1 from the left. Thus the cells can be labeled as a1, f23, etc.

    Input

    Input  consists of K + 1 lines: the first line contains the values M, N and K separated by one or several spaces; the next lines contain the labels of the cells where the queens are placed initially (one label per line).

    Output

    Output contains two lines. The first line contains the label of the cell where the queen should be places. (If there are several possible answers, pick the cell that is first in the lexicographic ordering of the cell labels). The second one contains the number of empty cells not under attack after the queen has been added.

    Sample Input

    4 4 2
    a1
    a2

    Sample Output

    c1
    2

    Source

    样例输入

    4 4 2
    a1
    a2

    样例输出

    c1
    2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部