<PREV Problem:
NEXT>
Solved by 51 users: ...
UserDateAttemptTimeCMSC
ignat02 nov 2010C++4100.59110 
ignat02 nov 2010C++3500.56114 
stasg721 jan 2011C600.54115 
ignat02 nov 2010C++3200.47117 
ignat02 nov 2010C++3300.47117 
stasg722 apr 2010C++100.54124 
tttttt07 may 2011C++1900.19148 
mikelan21 feb 2012C400.28148 
ignat24 apr 2010C++1300.47148 
strider22 apr 2010C100.55149 
decoherence11 sep 2010C1900.30152 
decoherence11 sep 2010C2300.30154 
ripatti23 apr 2010C++600.33160 
Grinchuk_17524 dec 2011C++1800.39160 
ripatti23 apr 2010C++700.30163 
evg28104 may 2010C++700.65164 
JohnJones_00101 aug 2011C400.37174 
ripatti23 apr 2010C++500.27177 
Languages
C++
37
C
13
Java
2
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 

Islands

Time limit = 1 second(s)

Memory limit = 33000 Kb

The scientists from Institute of Geodesy and Cartography made a satellite picture of some part of the Pacific Ocean. Then they composed a map of islands. But the map occurred quite large and they asked you for help. Do count a number of islands on the map.

Island is a set of square cells of land, where each cell is reachable from another by land. Each island is surrounded by water. No two islands contact by their corners. There are no lakes inside an island.

Input In the first line there are two space-separated numbers N and M — the hight and the width of a map ( 1 ≤ N, M ≤ 5000 ). Each of the next N lines contains M symbols describing the map: "~" stands for water, "*" stands for land.

Output The number of islands.

Input#1
7 6
~~~~~~
~*~**~
~***~~
~~~~~~
~*~~*~
~**~*~
~~~~~~
Output#1
3

Author:
Classical problem. Prepared by Semyonov Stanislav.
April 8, 2010

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 190ms

SW soft NIX
ID = 3.230.154.129