ISLAND_ATTACK - Island Under Attack!
Once upon a time, there were villagers who lived happily in Martian archipelago . Suddenly, Chris to van Necrophos , the most notorious wizard from the Offense of the Ancients , suddenly came there and started a havoc. At first, he started to use his spell to steal the life power of others. Luckily, there were some shelters that can protect the villagers from that spell, and there was still enough time for all of the villagers to go to any of the shelters available. Yet, the shelters were only able to hold some villagers. The wizard also created dark barriers in each islands so that every villagers could not escape from their islands. The magician also had a special ability that, if the numbers of the villagers that he had consumed in an island was more than half of the island's population, the whole island would be destroyed and consumed by the magician instead, including the shelters and the villagers inside.
Now, you are given a map of the place where Chris to attack. You need to determine how many people in all of those island would survive after the attack. the map will be in a size of N X M. The villagers will be denoted as "H". The shelters will be denoted by a number from 1-9, which is the number of villagers that can get inside the shelters. The sea water is denoted as "." and the land is denoted as "#". The area of lands is considered as the same island as long that the land is adjacent with any other entities except the sea water.
The area outside the provided map is considered as open sea, so they couldn't go out of the provided map.
Note: See input examples for clarification.
InputInput starts with an integer T (1 ≤ T ≤ 20), denoting the number of test cases. Each of the test cases consists of integer N and M (1 ≤ N,M ≤ 100), denoting the size of width and length of the map. After that, each testcases will have N more lines, which is the map at that time.
OutputFor each case print "Case #X: There are P survivors.", where X (1 ≤ X ≤ T) is the case number and P is the total number of villagers that could survive from that assault. If there are no survivors, then print "Case #X: There is no survivor.". If there is exactly one survivor, print "Case #X: There is 1 survivor." instead. There must be no trailing spaces at the end of printed lines, neither empty characters. Print a newline after each testcase.
Input: 1 4 7 ....##. #H3HH#. H#.#H#. ......# Output: Case #1: There are 3 survivors.
@hastananda can you please check my submission, Can you point out, what I am missing in my submission?
My assert on r,c>0 is failing
@hanstananda Please check my submission. Why am I getting WA?