Pro.ID22484 TitleGold Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22484 AC1 Submit20 Ratio5.00% 时间&空间限制描述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 Sample Output 2 3 Source 样例输入3 1 样例输出2 3 作者 |