22484_Gold

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

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

Pro.ID

22484

Title

Gold

Title链接

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

AC

1

Submit

20

Ratio

5.00%

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    One rogue entered into the dead well to dig the gold. The rogue is so powerful that he has ability calling "slink" for entering the well quietly and the masters couldn't discover him. But the slink ability spent him much energy and if the energy was too low, he was immediately caught by the masters and died. So he must arrange the digging plan.

    Dead well can be described as an n×n rectangle. For masters were so many that you can assume that everywhere were masters except the golden point (which had gold and the rogue wants to go most), the entrance and the exit. And then dead well was also a maze. The rogue can only walk into the master point, golden point, entrance and exit. He can walk four directions of north, south, east and west. When the rogue entered into the golden points, the entrance point, or the exit point, he can recover his energy in no time because there weren't any masters. Rogue must go out of the dead well at the exit point.

    You job is that to calculate how many golden points he can visit and how many master points he at least visited.

    输入

    This problem has multiple cases. In each case, the first line is two integers n ( 1 ≤ n ≤ 100 ) and m ( 0 ≤ m ≤ 200 ), which is the size of the dead well and the maximum master points he can slink at most. There n line of string without space. In each string, there are n characters. "E" stands for the entrance, "X" stands for the exit, "G" stands for the golden point, "-" stands for the master point, and "#"stands for the wall. You can assume that there are at most 16 golden points.

    The input is terminated by n=0.

    输出

    Description

    One rogue entered into the dead well to dig the gold. The rogue is so powerful that he has ability calling "slink" for entering the well quietly and the masters couldn't discover him. But the slink ability spent him much energy and if the energy was too low, he was immediately caught by the masters and died. So he must arrange the digging plan.

    Dead well can be described as an n×n rectangle. For masters were so many that you can assume that everywhere were masters except the golden point (which had gold and the rogue wants to go most), the entrance and the exit. And then dead well was also a maze. The rogue can only walk into the master point, golden point, entrance and exit. He can walk four directions of north, south, east and west. When the rogue entered into the golden points, the entrance point, or the exit point, he can recover his energy in no time because there weren't any masters. Rogue must go out of the dead well at the exit point.

    You job is that to calculate how many golden points he can visit and how many master points he at least visited.

    Input

    This problem has multiple cases. In each case, the first line is two integers n ( 1 ≤ n ≤ 100 ) and m ( 0 ≤ m ≤ 200 ), which is the size of the dead well and the maximum master points he can slink at most. There n line of string without space. In each string, there are n characters. "E" stands for the entrance, "X" stands for the exit, "G" stands for the golden point, "-" stands for the master point, and "#"stands for the wall. You can assume that there are at most 16 golden points.

    The input is terminated by n=0.

    Output

    In each test case, you must print two integers in one line. The first integer is the golden point he can dig at most and the second integer is the least master points he must visit when he digs the most gold mines. If it's impossible to go out of the dead well, print a string of "Impossible".

    Sample Input

    3 1
    E-G
    #G-
    --X
    0 0

    Sample Output

    2 3

    Source

    样例输入

    3 1
    E-G
    #G-
    --X
    0 0

    样例输出

    2 3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部