山东省赛ACM真题重点.docx

上传人:b****5 文档编号:3264370 上传时间:2022-11-21 格式:DOCX 页数:15 大小:38.29KB
下载 相关 举报
山东省赛ACM真题重点.docx_第1页
第1页 / 共15页
山东省赛ACM真题重点.docx_第2页
第2页 / 共15页
山东省赛ACM真题重点.docx_第3页
第3页 / 共15页
山东省赛ACM真题重点.docx_第4页
第4页 / 共15页
山东省赛ACM真题重点.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

山东省赛ACM真题重点.docx

《山东省赛ACM真题重点.docx》由会员分享,可在线阅读,更多相关《山东省赛ACM真题重点.docx(15页珍藏版)》请在冰豆网上搜索。

山东省赛ACM真题重点.docx

山东省赛ACM真题重点

ProblemAPhoneNumber

WeknowthatifaphonenumberAisanotherphonenumberB’sprefix,Bisnotabletobecalled.Foranexample,Ais123whileBis12345,afterpressing123,wecallA,andnotabletocallB.

GivenNphonenumbers,yourtaskistofindwhetherthereexitstwonumbersAandBthatAisB’sprefix.

Input

Theinputconsistsofseveraltestcases.

ThefirstlineofinputineachtestcasecontainsoneintegerN(0

ThenextlinecontainsNintegers,describingthephonenumbers.

Thelastcaseisfollowedbyalinecontainingonezero.

Output

Foreachtestcase,ifthereexitsaphonenumberthatcannotbecalled,print“NO”,otherwiseprint“YES”instead.

SampleInputOutputfortheSampleInput

2

012

012345

2

12

012345

0

NO

YES

ProblemBBalloons

BothSayaandKudolikeballoons.Oneday,theyheardthatinthecentralpark,therewillbethousandsofpeopleflyballoonstopatternabigimage.

Theywereveryinterestedaboutthisevent,andalsocuriousabouttheimage.

Sincetherearetoomanyballoons,itisveryhardforthemtocomputeanythingtheyneed.Canyouhelpthem?

YoucanassumethattheimageisanN*Nmatrix,whileeachelementcanbeeitherballoonsorblank.

SupposeelementAandelementBarebothballoons.Theyareconnectedif:

iTheyareadjacent;

iiThereisalistofelementC1,C2,…,Cn,whileAandC1areconnected,C1andC2areconnected…CnandBareconnected.

Andaconnectedblockmeansthateverypairofelementsintheblockisconnected,whileanyelementintheblockisnotconnectedwithanyelementoutoftheblock.

ToSaya,elementA

andB

isadjacentif

ButtoKudo,elementA

andelementB

isadjacentif

and

Theywanttoknowthatthere’showmanyconnectedblockswiththereowndefinitionofadjacent?

Input

Theinputconsistsofseveraltestcases.

ThefirstlineofinputineachtestcasecontainsoneintegerN(0

EachofthenextNlinescontainsastringwhoselengthisN,representstheelementsofthematrix.Thestringonlyconsistsof0and1,while0representsablockand1representsballoons.

Thelastcaseisfollowedbyalinecontainingonezero.

Output

Foreachcase,printthecasenumber(1,2…andtheconnectedblock’snumberswithSayaandKudo’sdefinition.Youroutputformatshouldimitatethesampleoutput.Printablanklineaftereachtestcase.

SampleInputOutputfortheSampleInput

5

11001

00100

11111

11010

10010

0

Case1:

32

ProblemCClockwise

SayahavealongnecklacewithNbeads,andshesignsthebeadsfrom1toN.ThenshefixesthemtothewalltoshowN-1vectors–vectoristartsfrombeadiandendupwithbeadi+1.

Oneday,KudocomestoSaya’shome,andsheseesthebeadsonthewall.Kudosaysitisnotbeautiful,andletSayamakeitbetter.

Shesays:

“Ithinkitwillbebetterifitisclockwiserotation.Itmeansthattoanyvectori(i-1,itwillhavethesamedirectionwithvectori+1afterclockwiserotateTdegrees,while0≤T<180.”

ItishardforSayatoresetthebeads’places,soshecanonlyremovesomebeads.Tosavingthebeads,althoughsheagreeswithKudo’ssuggestion,shethinkscounterclockwiserotationisalsoacceptable.Acounterclockwiserotationmeanstoanyvectori(i-1,itwillhavethesamedirectionwithvectori+1aftercounterclockwiserotateTdegrees,while0≤180.”

Sayastartstocomputeatleasthowmanybeadssheshouldremovetomakeaclockwiserotationoracounterclockwiserotation.

Sincethenecklaceisvery-verylong,canyouhelphertosolvethisproblem?

Input

Theinputconsistsofseveraltestcases.

ThefirstlineofinputineachtestcasecontainsoneintegerN(2

EachofthenextNlinescontainstwointegerxandy,representsthecoordinateofthebeads.Youcanassumethat0

Thelastcaseisfollowedbyalinecontainingonezero.

Output

Foreachcase,printyouranswerwiththefollowingformat:

Ifitisclockwiserotationwithoutremovinganybeads,pleaseprint“C;otherwiseifitiscounterclockwiserotationwithoutremovinganybeads,print“CC”instead;otherwise,supposeremoveatleastxbeadstomakeaclockwiserotationandremoveatleastybeadstomakeacounterclockwiserotation.Ifx≤y,print“Removexbead(s,C”,otherwiseprint“Removexbead(s,CC”instead.

Youroutputformatshouldimitatethesampleoutput.Printablanklineaftereachtestcase.

SampleInputOutputfortheSampleInput

3

11

22

33

3

p11

22

pspan11p

4

11

22

33

22

0

C

CC

Remove1bead(s,C

ProblemDShopping

SayaandKudogoshoppingtogether.

Youcanassumethestreetasastraightline,whiletheshopsaresomepointsontheline.

Theyparktheircarattheleftmostshop,visitalltheshopsfromlefttoright,andgobacktotheircar.

Yourtaskistocalculatethelengthoftheirroute.

Input

Theinputconsistsofseveraltestcases.

ThefirstlineofinputineachtestcasecontainsoneintegerN(0

ThenextlinecontainsNintegers,describingthesituationoftheshops.Youcanassumethatthesituationsoftheshopsarenon-negativeintegerandsmallerthan2^30.

Thelastcaseisfollowedbyalinecontainingonezero.

Output

Foreachtestcase,printthelengthoftheirshoppingroute.

SampleInputOutputfortheSampleInput

4

24138937

6

73041143942

0

152

70

Explanationforthefirstsample:

Theyparktheircaratshop13;gotoshop24,37and89andfinallyreturntoshop13.Thetotallengthis(24-13+(37-24+(89-37+(89-13=152

ProblemEEmergency

Kudo’srealnameisnotKudo.HernameisKudryavkaAnatolyevnaStrugatskia,andKudoisonlyhernickname.

Now,sheisfacinganemergencyinherhometown:

Hermotherisdevelopinganewkindofspacecraft.Thisplancostsenormousenergybutfinallyfailed.What’smore,becauseofthefailedproject,thegovernmentdoesn’thaveenoughresourcetakemeasuretotherisingsealevelscausedbyglobalwarming,leadtoanislandfloodedbythesea.

Dissatisfiedwithhermother’sspacecraftandthegovernment,civilwarhasbrokenout.Thefoewantstoarrestthespacecraftproject’sparticipantsandthe“Chiefcriminal”–Kudo’smother–DoctorT’sfamily.

Atthebeginningofthewar,allthecitiesareoccupiedbythefoe.Butastimegoesby,thecitiesrecapturedonebyone.

Topreventfromthefoe’sarrestandboostmorale,Kudoandsomeotherpeoplehavetodistractfromacitytoanother.Althoughtheycanusesomeothermeanstotransport,themostconvenientwayisusingtheinter-cityroads.Assumingthecityasanodeandaninter-cityroadasanedge,youcantreatthemapasaweighteddirectedmultigraph.Aninter-cityroadisavailableifbothitsendpointisrecaptured.

Herecomestheproblem.

Giventhetrafficmap,andtherecapturedsituation,canyoutellKudowhat’stheshortestpathfromonecitytoanotheronlypassingtherecapturedcities?

Input

Theinputconsistsofseveraltestcases.

ThefirstlineofinputineachtestcasecontainsthreeintegersN(0

EachofthenextMlinescontainsthreeintegerx,yandz,representsthereisaninter-cityroadstartsfromx,endupwithyandthelengthisz.Youcanassumethat0

EachofthenextQlinescontainstheoperationswiththefollowingformat:

a0x–meanscityxhasjustbeenrecaptured.

b1xy–meansaskingtheshortestpathfromxtoyonlypassingtherecapturedcities.

Thelastcaseisfollowedbyalinecontainingthreezeros.

Output

Foreachcase,printthecasenumber(1,2…first.

Foreachoperation0,ifcityxisalreadyrecaptured(thatis,thesame0xoperationappearsagain,print“Cityxisalreadyrecaptured.”

Foreachoperation1,ifcityxoryisnotrecapturedyet,print“Cityxoryisnotavailable.”otherwiseifKudocangofromcityxtocityyonlypassingtherecapturedcities,printtheshortestpath’slength;otherwiseprint“Nosuchpath.”

Youroutputformatshouldimitatethesampleoutput.Printablanklineaftereachtestcase.

SampleInputOutputfortheSampleInput

336

011

121

023

102

00

02

102

120

02

000

Case1:

City0or2isnotavailable.

3

Nosuchpath.

City2isalreadyrecaptured.

ProblemFFairytale

Itissaidthatinaschool’sunderground,thereisahugetreasurewhichcanmeetanydesireoftheowner.

TheSpyUnion(SUisveryinterestinthislegend.Aftermuchinvestigation,SUfinallygettheanswerandlettheyoungestspysneakintotheschool.That’swhySayaisnowhere.

Today,Sayafoundtheentranceeventually.

Sheenterstheentrance,andfoundherinafairy-taleworld.

“Welcome!

”saysafairy,“IamIvan.Myresponsibilityistoprotectthetreasure,andgiveittotheonewhohavetheabilitytoownit.”

ThenIvangivesSayathreeproblems.

Withyourhelp,Sayafinishedthefirstandthesecondproblem(ProblemHandI.Herecomesthethird.IfSayacansolvethisproblem,thetreasurebelongstoher.

Thereisabigmazeprotectingthetreasure.YoucanassumethemazeasanN*NmatrixwhileeachelementinthematrixmightbeN(North,S(South,W(WestorE(East.Atfirst,Sayaisattheelement(1,1–thenorth-westcorner,andthetreasureisat(N,N–thesouth-eastcorner.

Thedesignerhaveenchanttothismatrix,sothatthetreasuremightmovefromtimetotimerespectingthefollowingrules:

Supposethetreasureisinanelementwhichmarked

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

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

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

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