acm试题选做.docx

上传人:b****7 文档编号:10572856 上传时间:2023-02-21 格式:DOCX 页数:17 大小:55.32KB
下载 相关 举报
acm试题选做.docx_第1页
第1页 / 共17页
acm试题选做.docx_第2页
第2页 / 共17页
acm试题选做.docx_第3页
第3页 / 共17页
acm试题选做.docx_第4页
第4页 / 共17页
acm试题选做.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

acm试题选做.docx

《acm试题选做.docx》由会员分享,可在线阅读,更多相关《acm试题选做.docx(17页珍藏版)》请在冰豆网上搜索。

acm试题选做.docx

acm试题选做

Description

Michael喜欢滑雪百这并不奇怪,因为滑雪的确很刺激。

可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。

Michael想知道载一个区域中最长底滑坡。

区域由一个二维数组给出。

数组的每个数字代表点的高度。

下面是一个例子

12345

161718196

152425207

142322218

131211109

一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。

在上面的例子中,一条可滑行的滑坡为24-17-16-1。

当然25-24-23-...-3-2-1更长。

事实上,这是最长的一条。

Input

输入的第一行表示区域的行数R和列数C(1<=R,C<=100)。

下面是R行,每行有C个整数,代表高度h,0<=h<=10000。

Output

输出最长区域的长度。

SampleInput

55

12345

161718196

152425207

142322218

131211109

SampleOutput

25

Source

SHTSC2002

∙Submit

∙Status

∙SeeSolution

Description

Techniciansinapathologylabanalyzedigitizedimagesofslides.Objectsonaslideareselectedforanalysisbyamouseclickontheobject.Theperimeteroftheboundaryofanobjectisoneusefulmeasure.Yourtaskistodeterminethisperimeterforselectedobjects.

Thedigitizedslideswillberepresentedbyarectangulargridofperiods,'.',indicatingemptyspace,andthecapitalletter'X',indicatingpartofanobject.Simpleexamplesare

XXGrid1.XXXGrid2

XX.XXX

.XXX

...X

..X.

X...

AnXinagridsquareindicatesthattheentiregridsquare,includingitsboundaries,liesinsomeobject.TheXinthecenterofthegridbelowisadjacenttotheXinanyofthe8positionsaroundit.ThegridsquaresforanytwoadjacentX'soverlaponanedgeorcorner,sotheyareconnected.

XXX

XXXCentralXandadjacentX's

XXX

AnobjectconsistsofthegridsquaresofallX'sthatcanbelinkedtooneanotherthroughasequenceofadjacentX's.InGrid1,thewholegridisfilledbyoneobject.InGrid2therearetwoobjects.Oneobjectcontainsonlythelowerleftgridsquare.TheremainingX'sbelongtotheotherobject.

ThetechnicianwillalwaysclickonanX,selectingtheobjectcontainingthatX.Thecoordinatesoftheclickarerecorded.Rowsandcolumnsarenumberedstartingfrom1intheupperlefthandcorner.ThetechniciancouldselecttheobjectinGrid1byclickingonrow2andcolumn2.ThelargerobjectinGrid2couldbeselectedbyclickingonrow2,column3.Theclickcouldnotbeonrow4,column3.

Oneusefulstatisticistheperimeteroftheobject.AssumeeachXcorrespondstoasquareoneunitoneachside.HencetheobjectinGrid1hasperimeter8(2oneachoffoursides).TheperimeterforthelargerobjectinGrid2isillustratedinthefigureattheleft.Thelengthis18.

Objectswillnotcontainanytotallyenclosedholes,sotheleftmostgridpatternsshownbelowcouldNOTappear.Thevariationsontherightcouldappear:

ImpossiblePossible

XXXXXXXXXXXXXXXX

X..XXXXXX...X...

XX.XXXXXXX.XXX.X

XXXXXXXXXXXXXX.X

....................

..X....X....X....X..

.X.X..XXX..X........

..X....X....X....X..

....................

Input

Theinputwillcontainoneormoregrids.Eachgridisprecededbyalinecontainingthenumberofrowsandcolumnsinthegridandtherowandcolumnofthemouseclick.Allnumbersareintherange1-20.Therowsofthegridfollow,startingonthenextline,consistingof'.'and'X'characters.

Theendoftheinputisindicatedbyalinecontainingfourzeros.Thenumbersonanyonelineareseparatedbyblanks.Thegridrowscontainnoblanks.

Output

Foreachgridintheinput,theoutputcontainsasinglelinewiththeperimeterofthespecifiedobject.

SampleInput

2222

XX

XX

6423

.XXX

.XXX

.XXX

...X

..X.

X...

5613

.XXXX.

X....X

..XX.X

.X...X

..XXX.

7726

XXXXXXX

XX...XX

X..X..X

X..X...

X..X..X

X.....X

XXXXXXX

7744

XXXXXXX

XX...XX

X..X..X

X..X...

X..X..X

X.....X

XXXXXXX

0000

SampleOutput

8

18

40

48

8

Source

Mid-CentralUSA2001

∙Submit

∙Status

∙SeeSolution

Copyright©2008-2012BJTU-OJTeam.AllRightsReserved.

BeijingJiaotongUniversityOnlineJudgeZhiXingversionr163

Description

PlanetCucurbitaisinhabitedwithintelligentpumpkins.Thesepumpkinsarenotonlyextremelyclever,theyalsoarefondoftourism.OneoftheirmainroutesistheEarthduringHalloween.

Asyouknow,pumpkinscannotmovebythemselves(intelligentpumpkinsarenotanexception),sotheymakesomebodyelsetotransportthem.InthecaseofHalloweenthisisdonebyhumans.First,theymakepeopletogrowspecialbiologicaldockingstations,thenpreparethestations(peoplecutspecialholes,firecandlesetc?

youknowtheprocedure),andafterthesepreparationspumpkinscomeandhavefun.Peopleusuallydonotseeanythingandthinkthatthisisjustaholidayandthatthisholidayisforhumans,butremember?

ifsomebodyisfrightenedatHalloween,hewasfrightenednotbyhisnot-very-friendlyfriends,butbyalienpumpkins.

Tousethebiologicaldockingstation,apumpkinmusthaveaspecialtransmitter.It’smainelementsaretworingsmadeofgoldandforsomeunexplainablereasonstheseringsshouldbecutfromoneroundplate.Thesizesoftheserings(innerandouterradii)arepumpkin-specific,soeachalienshouldorderaspecialsetforhimself.

Mr.Calabaza,anadolescentpumpkin,wantstomakehisfirsttriptotheEarth.Hefoundadiscountplate,whichwasnotredeemedbyapreviouscustomer,anditisnecessarytocheck,whetherthisplateallowsMr.Calabazatocuttheringsheneedsfromit,orheshouldorderanewlargerplate.

Input

TheinputfilecontainsfiveintegernumbersA,a,B,b,P(0

Output

Outputaword“YES”iftheplatesuitsMr.Calabaza,oraword“NO”ifheneedstoorderanotherone.

SampleInput

21536

SampleOutput

YES

Source

NortheasternEurope2006,NorthernSubregion

∙Submit

∙Status

∙SeeSolution

Copyright©2008-2012BJTU-OJTeam.AllRightsReserved.

BeijingJiaotongUniversityOnlineJudgeZhiXingversionr163

Description

XiaoxandMadongflyarenotinterestedinthepoliticaltheorycourse,andtheydecidedtoplayagamewiththecoinsduringtheclass.

Firstly,Xiaoxwilllinethencoinswiththeheadsideupandlabelthecoinsfrom1ton(1≤n≤10000).ThenXiaoxcanchoosetwooperationsasfollows:

Op1:

Xiaoxchoosesanintegerm(1≤m≤n)andasksMadongflytoturnoverthecoinwhichislabeledm.

Op2:

Xiaoxchoosesanintegerm(1≤m≤n)andasksMadongflytoanswerthelabelofthecoinwhichisthem-thonewiththeheadsideup.Itispossiblethatthetotalnumberofthecoinswiththeheadsideupislessthanm.

XiaoxcanchooseOp1orOp2ashewants.MadongflyshouldgivetheanswertotheOp2assoonaspossible,whichmakeshimembarrassed.YouareunluckytositnexttoMadongflyandheturnstoyouforsomehelp.

AsthebestprogrammerinBJTU,canyoudesignaprogramtohelpMadongflyinyoursparetime?

Input

Thereisonlyonecaseoftestingdata.

Thefirstlineisanintegern,whichisthenumberofcoinsXiaoxhas.

ThesecondlineisanintegerL,whichshowsthetimesofoperationXiaoxwouldcarryout(1≤L≤20000).

Thefollowingeachline,withtwointegersmodelandm,standsfortheoperationXiaoxwouldmake.Ifthemodelis1,XiaoxmakestheOp1andMadongflyturnsoverthecoinlabeledm.Ifthemodelis2,XiaoxmakestheOp2andMadongflyanswersthelabelofthecoinwhichisthem-thonewiththeheadsideup.

Output

AccordingtoeveryOp2intheinput,theoutputshowsthelabelofthecoinwhichisthem-thonewiththeheadsideup.

Ifthetotalnumberofthecoinswiththeheadsideupislessthanm,pleaseoutput“NO”.

Eachanswershowsinoneline.

SampleInput

5

8

23

13

23

12

23

24

11

21

SampleOutput

3

4

5

NO

4

Source

1stBJTUProgrammingContest

∙Submit

∙Status

∙SeeSolution

Copyright©2008-2012BJTU-OJTeam.AllRights

Description

FarmerJohnwantshiscowstohelphimmakealake.HehasmappedthepasturewherehewantstobuildthelakebycreatingaR(3<=R<=100)rowbyC(3<=C<=100)columngridofsixfootbysixfootsquaresandthenbydeterminingtheaverageelevation(10<=elev_rc<=5000)ininchesforeachsquare.

Additionally,hehastrainedthecowsin"stompdigging".Theburlybovinestravelinaherdthatjustexactlycoversa3x3gridofsquarestoagridwhoseupperleftcoordinateisR_s,C_s(1<=R_s<=R-2;1<=C_s<=C-2).ThecowsthenstompthegroundtopushitdownD_s(1<=D_s<=40)inches.Thecowsarequitemeticulous;thecowsatlowerelevationswillnotcommencestompinguntiltherestoftheherdhasjoinedthem.Thus,notallthe3x3gridisnecessarilystomped(orperhapssomepartisstompedlessthansomeotherpart).

Givenaninitialsetofelevations,anorderedsetofN(1<=N<=20000)stompdigginginstructions,andanelevationE(0<=E<=5000)forthelake'sfinalwaterlevel,determinethevolumeofwater(incubicinches)thatthelakewillhold.Itisguaranteedthattheanswerwillnotexceed2,000,000,000.Presumethattheedgeofthelakecontainsbarrierssothatwatercannotspillovertheborder.

Considerasmall4x6pasturetobeturnedintoalake.Itsinitialelevations(annotatedwithrow/columnnumbers)are:

column

123456

row1:

282520323436

row2:

272520203034

row3:

242020202030

row4:

202014142020

Interpretingthemap,weseeahillintheupperrightcornerthatrisestoelevation36;asmallhillalsorisestoelevation28intheupperleftcorner.Themiddleofrow4hasaslightdepression.

Afterthecow-stompinginstruction"144",thepasturehastheseelevations:

123456

row1:

282520323232

row2:

272520203032

row3:

242020202030

row4:

202014142020

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 历史学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1