Sie sind auf Seite 1von 2

# 10/16/2016

## Problem - 723D - Codeforces

Gamoool|Logout

HOME

PROBLEMS

CONTESTS
SUBMIT

STATUS

GYM

PROBLEMSET

STANDINGS

GROUPS

RATING

API

SECTIONS

CUSTOM TEST

CodeforcesRound#375(Div.2)

D.LakesinBerland

Finished

timelimitpertest: 2seconds
memorylimitpertest: 256megabytes
input: standardinput
output: standardoutput
ThemapofBerlandisarectangleofthesizenm,whichconsistsofcellsofsize11.
Eachcelliseitherlandorwater.Themapissurroundedbytheocean.
Lakesarethemaximalregionsofwatercells,connectedbysides,whicharenotconnected
withtheocean.Formally,lakeisasetofwatercells,suchthatit'spossibletogetfromanycell
watercelltothesetsuchthatitwillbeconnectedwithanyothercell.

Practice

Virtualparticipation

Thefirstlineoftheinputcontainsthreeintegersn,mandk(1n,m50,0k50)
thesizesofthemapandthenumberoflakeswhichshouldbeleftonthemap.

Thenextnlinescontainmcharacterseachthedescriptionofthemap.Eachofthe
charactersiseither'.'(itmeansthatthecorrespondingcelliswater)or'*'(itmeansthatthe
correspondingcellisland).
Itisguaranteedthatthemapcontainatleastklakes.

Output

Startvirtualcontest

Submit?
Language:
Choose
file:

Examples

input
541
****
*..*
****
**.*
..**

GNUG++115.1.0
ChooseFile

Nofilechosen

Becareful:thereis50pointspenaltyforsubmission
whichfailsthepretestsorresubmission(except
failureonthefirsttest,denialofjudgementor
similarverdicts)."Passedpretests"submission
verdictdoesn'tguaranteethatthesolutionis
absolutelycorrectanditwillpasssystemtests.

Inthefirstlineprinttheminimumnumberofcellswhichshouldbetransformedfromwaterto
land.
Inthenextnlinesprintmsymbolsthemapafterthechanges.Theformatmuststrictly
followtheformatofthemapintheinputdata(thereisnoneedtoprintthesizeofthemap).If

Virtualcontestisawaytotakepartinpastcontest,
ascloseaspossibletoparticipationontime.Itis
supportedonlyACMICPCmodeforvirtual
contests.Ifyou'veseentheseproblems,avirtual
contestisnotforyousolvetheseproblemsinthe
archive.Ifyoujustwanttosolvesomeproblem
fromacontest,avirtualcontestisnotforyou
solvethisprobleminthearchive.Neveruse
communicatewithotherpersonduringavirtual
contest.

exactlyklakesinBerland.Notethattheinitialnumberoflakesonthemapisnotlessthank.

Input

Submit

Problemtags

## dfsandsimilar dsu greedy

Notageditaccess

Contestmaterials

Announcement
Tutorial

output
1
****
*..*
****
****
..**

input
330
***
*.*
***

output
1
***
***

http://codeforces.com/problemset/problem/723/D

1/2

10/16/2016

## Problem - 723D - Codeforces

***
***

Note
Inthefirstexamplethereareonlytwolakesthefirstconsistsofthecells(2,2)and(2,3),
thesecondconsistsofthecell(4,3).Itisprofitabletocoverthesecondlakebecauseitis
smaller.Payattentionthattheareaofwaterinthelowerleftcornerisnotalakebecausethis
areashareaborderwiththeocean.