ZOJ Problem Set - 1603
Several pieces of cloth are laid out on the table without overlapping each
other. These pieces contain many holes, some so big that entire other piece
of cloth may fit into them. Digital black-and-white image of the tabletop was
taken, on which areas covered by cloth are represented with '*'s and not covered
areas with '.'s. A single piece of cloth is thus represented with 4-connected
area of '*'s - i.e., a group of '.'s located next to each other horizontally
or vertically, but not diagonally.
For example, on the image on the left there are three pieces - one without
holes, and two with one hole each - first has area of 8, and the second - area
Process to the end of file.
Source: Northeastern Europe 2001, Far-Eastern Subregion