Question: Can someone solve this HackerRank Contest Question: Forest Fires MPC2014 Question Problem The input will contain a 10x10 map. On this map you will see

Can someone solve this HackerRank Contest Question: Forest Fires MPC2014 QuestionCan someone solve this HackerRank Contest Question: Forest Fires MPC2014 Question ProblemThe input will contain a 10x10 map. On this map you willsee the following symbols::.- blank space, which is fire neutral (ex. sand

Problem The input will contain a 10x10 map. On this map you will see the following symbols::.- blank space, which is fire neutral (ex. sand or rock) .T-a tree F-a tree on fire .W - water FIRES only spread from existing fire to adjacent trees, in 4 directions (so not diagonally). It takes 1 unit of time for the fire to spread from one location to the next in the 4 available directions. Assume that once a square become 'F', it stays that way until the end of the test case. The fire spreads in all 4 directions at the same time. If TREES have water in at least one of their 4 directions, then they cannot catch fire until their water is evaporated. WATER becomes evaporated if fire touches it from ANY direction (take that Pokemon physics, fire beats water in MPC!). So 'W' becomes '' NEXT TIME UNIT if Fis in at least one of its 8 surrounding squares. When water is evaporated, it can no longer protect the trees from fire. If fire meets a tree (F meets T) then the tree becomes a fire as well. Assume that all of these mentioned events are all updated at the same unit of time. The output will be one integer: the time it takes for the fire to capture the entire forest. If some piece of the forest survives indefinately, output-1. Input One spruced up forest (hehe). A forest consists of 10 lines. Each line consists of spaced characters that may be ",, 'F, 'W' or 'T'. Output Output An integer representing the time for the forest to burn down. -1 indicates that the forest does not burn down. Input Test Case 1 ..ITWTTT.. ..F...... Output Test Case 1 -1 The water evapotates and turns into '', but the fire can't reach all of the forest! Input Test Case 2 ...TTT..... ...TWTTT.. ...F...... Output Test Case 2 8 In the first unit of time, the water evaporates and the next 7 units of time the fire takes out the forest

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!