Game

TimeLimit:1000MS  MemoryLimit:65536KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
  Sea5 and wzh are playing games.

  There are some guards on an n × m chessboard. Every guard can attack eight cells around him and release shockwave to attack the whole row and column where he stand.

  Sea5 and wzh are at the beginning stage of the game, they have already put some guards on the chess cells. No guards can be attacked by another guard right now. So they all fell asleep.

  An innocent passer-by is on the chessboard. He can move to up, down, left or right from where he stands. The guards won’t attack him unless the passer-by move to where they stand. The innocent man may appear at any point on the chessboard and move to any point.

  The innocent passer-by wants to know the average shortest distance of all the ways he can move without attacked by guards.
Input
  Multiple test cases.

  The first line is an integer $T (T \leq 50)$, the number of cases.

  For each case, first line is two integers $n$ and $m (2 \leq n, m, \leq 1000)$.

  The next $n$ lines contain $m$ symbols indicate the cells of chessboard. ‘G’ indicates a guard and ‘#’ indicates an empty cell.
Output
  One line per case, shortest distance of all the ways the passer-by can move without attacked by guards.

  Round the answer to four decimals.
SampleInput
1
2 2
##
G#
SampleOutput
0.8889

 Hint Ways of distance 0: 3 Ways of distance 1: 4 Ways of distance 2: 2 The answer is (3 * 0 + 1 * 4 + 2 * 2) / (3 + 4 + 2)
Submit
题目统计信息详细
总AC数1
通过人数1
尝试人数2
总提交量2
AC率50.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: