HFLOOR - Hotel Floors

no tags 

We are given a top view of a hotel floor, which is represented by an MxN matrix of characters, composed of (only) the following:

  • '#' is a Wall
  • '-' is Free Space
  • '*' is an occupied space (by a single person).

We are required to evaluate the average number of people living in a room.

Constraints

M, N <= 100
Number of test-cases <= 10
All border edges of the map will be walls.
There will be at least one room.

Input

The 1st line contains the number of test inputs, with each test case consisting of:
M N
MxN matrix of characters

Output

For each test case output a line with the average number of people living per room, rounded to exactly two decimal places.

Example

Input:
2
5 5
#####
#**##
###*#
#**##
#####
6 10
##########
#---*--*##
###-*----#
#**#######
##***---##
##########

Output:
1.67
4.00

hide comments
dragoncat: 2022-03-28 19:00:56

Can anyone explain for me why test case 2 is 4?

[Simes]: there are two rooms, one with 3 people, the other with 5, so the average number of people per room is 4.

Last edit: 2022-12-05 07:33:27
shwetar4252: 2021-07-17 12:03:39

how can i find answer to this problem
??

[NG]: By what we call "solving" here.

Last edit: 2021-07-25 22:57:24
ngominhtu237: 2017-02-08 15:15:05

I get wrong answer by using DFS , i don't now why Manuel Acosta

Manuel Acosta: 2016-03-25 21:15:12

Great problem, watch for the output, 1 WA for a empty space.


Added by:Prasanna
Date:2006-01-12
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS PERL6 VB.NET
Resource: ByteCode '06