117 - ZOJ Monthly, June 2012 - I
Consider there is a one floor frame structure. The roof is supported by several beams and the beams are supported by some columns. The roof is an n * m rectangle. The main beams are all paralleled to the edges of the roof. And the main beams are all in the range of the roof. There are some columns to support the roof or the main beams. The structure engineers think the structure is not strong enough, so they add some reinforce bars to connect the columns. This structure is made by standard structure members. So the distance between adjacent columns is 1, the length of each main beam is 1, and the length of each reinforce bar is sqrt(2), which means the angles between the main beams and the reinforce bars are all 45 degrees. In fact, every crossing point of the beams is supported by a column, and between every two adjacent columns, there will be at least one beam. There may be two or more beams or reinforce bars between two adjacent columns. The main structure is made by wood, so it is afraid of fire. The beams and the reinforce bars are easy to burn. The room now is nearly empty, the floor and the roof is made by other materials which are hard to burn. So we can consider that if it catches fire near one of the columns, the only way fire can spread is along the beams and reinforce bars. The fire can also spread through the crossing point of the reinforce bars. If more than 50% of the columns catch fire the whole structure will failed. Because the materials of the structrue members are not stable, each structure member has a fire spread speed s, the time for fire spread from one end to the other is the length divide the speed.
Now the owner of this house wants to know if one of the columns catches fire, for the worst situation how long the maximum time for him to escape is.
There are several test cases.
For each test cases, you should print one line contains one real number,
for the worst situation the maximum time can the people in the building escape,
round to 3 digits after decimal point.
1 1 6 0 0 1 1 2 0 0 0 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 0 1 1 0 0 1 2 1 1 6 0 0 1 1 0.5 0 0 0 1 2 0 0 1 0 2 1 1 0 1 2 1 1 1 0 2 1 0 0 1 2
Author: LI, Tierui