当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4478:Where is the King

题目描述
  There is a King placed on an N * N chessboard. In each second, Bob must move the King to the next cell in one of the eight directions, but he can not move the King to the outside of the chessboard, and can not move the King to a damaged cell. Note: If and only if there is not any next cell that he can place the King on in the eight directions, the King will stay in the same cell.
Now your task is to calculate that, after T seconds, the number of the cells that the King could be on.
输入解释
  There is an integer C (1 <= C <= 500) in the first line, indicates there are C test cases in total.
  For each test case, there are four integers N (2 <= N <= 100), T (1 <= T <= 1000000000), X (1 <= X <= N), Y (1 <= Y <= N). N and T have the same meaning as above, (X, Y) indicates the King’s initial location. Then there are N lines. In each line, there is a string with N characters include “#” and “.”, which indicates the states of the cells in this row. “#” means this cell is damaged, and “.” means this cell is ordinary. You can assume (X, Y) is an ordinary cell.
  For the coordinate (x, y), it stands for the cell in row x and column y. The coordinate of the top-left cell is (1, 1), and the coordinate of the bottom-right cell is (N, N).
输出解释
  For each test case, you should output the correct answer of the above task in one line.
输入样例
3
3 1 3 3
...
...
...
3 2 3 3
...
..#
.#.
3 4 1 3
.#.
.##
...
输出样例
3
6
1
提示
For Sample 1, the blue cells in the left picture of the Figure 1 show the cells that the King could be on after 1 second.
  For Sample 2, the blue cells in the right picture of the Figure 1 show the cells that the King could be on after 2 seconds.
The red cells stand for the damaged cells, and the yellow cells shows other ordinary cells. 
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4478

最后修改于 2020-10-25T23:13:54+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)