Você está na página 1de 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
ofthesettoanyotherwithoutleavingthesetandmovingonlytocellsadjacentbytheside,
noneofthemislocatedontheborderoftherectangle,andit'simpossibletoaddonemore
watercelltothesetsuchthatitwillbeconnectedwithanyothercell.

Practice

Virtualparticipation

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

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

Output

Startvirtualcontest

Submit?
Language:
Choose
file:

Itisguaranteedthattheanswerexistsonthegivendata.

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
thereareseveralanswers,printanyofthem.

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

Youtaskistofillupwiththeearththeminimumnumberofwatercellssothattherewillbe
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.

Codeforces(c)Copyright20102016MikeMirzayanov
TheonlyprogrammingcontestsWeb2.0platform
Servertime:Oct/16/201609:22:12UTC+2(p1).
Desktopversion,switchtomobileversion.

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

2/2