ACM杯比赛往年试题集锦.docx
《ACM杯比赛往年试题集锦.docx》由会员分享,可在线阅读,更多相关《ACM杯比赛往年试题集锦.docx(18页珍藏版)》请在冰豆网上搜索。
ACM杯比赛往年试题集锦
参赛资格与报名:
1、参赛者的范围包括:
各高校在校本科生、硕士生、博士生,以及被北京大学预录取的应届高三保送生。
其他人员如欲报名,请先询组委会。
2、竞赛以组队形式进行,每支队伍一名、两名或三名队员,设队长一名。
3、参赛队在截止时间前下载报名表并提交,组委会在收到报名后会给予回复。
4、外校参赛队如有需要,可向组委会申请提供邀请函。
5、本次竞赛不收取报名费。
竞赛流程与规则:
1、参赛者应当在竞赛的前一天查看竞赛网站,或检查报名时所留的邮箱,以了解第二天竞赛细节方面可能的变动,并阅读最新通知。
2、参赛者须携带以下证件进入考场:
*校园卡或学生证(北京大学在校生)
*学生证,和有效身份证件(其它高校在校生)
*学生证、北京大学预录取通知书,和有效身份证件(应届高三保送生)
有效身份证件,是指以下证件之一:
身份证、护照、往来港澳通行证,或户口簿(仅适用于未满16周岁的参赛者)。
3、参赛者可以携带书、手册、英语词典、程序清单等纸质参考资料;但不得携带任何电子媒质的资料,例如移动硬盘、U盘、光盘、电子词典等。
4、每支队伍只能使用一台计算机,所有队伍使用计算机的规格配置均相同。
5、竞赛时可能会提供打印服务,参赛者可向赛场工作人员提出。
6、竞赛当天提供饮用水、巧克力(或其它食品),无需自备午餐。
评奖:
1、参赛队正确解答试题的数量,是评奖的依据。
2、如果多支队伍解题数量相同,则根据总用时加上惩罚时间进行排名。
总用时和惩罚时间由每道解答正确的试题的用时加上惩罚时间组成。
每道试题用时将从竞赛开始到试题解答被判定为正确为止,期间每一次错误的提交将被加罚20分钟时间,未正确解答的试题不计时。
3、竞赛设一、二、三等奖,具体数量由组委会在竞赛结束后,根据结果决定。
4、竞赛设最佳女生奖,颁给排名最高的女生队。
所谓女生队,是指所有队员均为女生的参赛队。
硬件平台:
CPU 3.0GHz(HT)
RAM 1GB
硬盘 80GB
显示器 17英寸
键盘 国际标准键盘
鼠标 光电鼠标
软件平台:
Windows2000Professional或WindowsXP
MicrosoftVisualC++6.0
Eclipse3.2
Dev-C++4.9.9.2
Area
TimeLimit:
1000MS
MemoryLimit:
10000K
TotalSubmissions:
6845
Accepted:
1856
Description
Youaregoingtocomputetheareaofaspecialkindofpolygon.Onevertexofthepolygonistheoriginoftheorthogonalcoordinatesystem.Fromthisvertex,youmaygostepbysteptothefollowingvertexesofthepolygonuntilbacktotheinitialvertex.ForeachstepyoumaygoNorth,West,SouthorEastwithsteplengthof1unit,orgoNorthwest,Northeast,SouthwestorSoutheastwithsteplengthofsquarerootof2.
Forexample,thisisalegalpolygontobecomputedanditsareais2.5:
Input
Thefirstlineofinputisanintegert(1<=t<=20),thenumberofthetestpolygons.Eachofthefollowinglinescontainsastringcomposedofdigits1-9describinghowthepolygonisformedbywalkingfromtheorigin.Here8,2,6and4representNorth,South,EastandWest,while9,7,3and1denoteNortheast,Northwest,SoutheastandSouthwestrespectively.Number5onlyappearsattheendofthesequenceindicatingthestopofwalking.Youmayassumethattheinputpolygonisvalidwhichmeansthattheendpointisalwaysthestartpointandthesidesofthepolygonarenotcrosstoeachother.Eachlinemaycontainupto1000000digits.
Output
Foreachpolygon,printitsareaonasingleline.
SampleInput
4
5
825
6725
6244865
SampleOutput
0
0
0.5
2
Source
POJMonthly--2004.05.15LiuRujia@POJ
[Submit] [GoBack] [Status] [Discuss]
HomePage
GoBack
Totop
AllRightsReserved2003-2007YingFuchen,XuPengcheng,XieDi
Anyproblem,PleaseContact
BalancingAct
TimeLimit:
1000MS
MemoryLimit:
65536K
TotalSubmissions:
4447
Accepted:
1756
Description
ConsideratreeTwithN(1<=N<=20,000)nodesnumbered1...N.Deletinganynodefromthetreeyieldsaforest:
acollectionofoneormoretrees.DefinethebalanceofanodetobethesizeofthelargesttreeintheforestTcreatedbydeletingthatnodefromT.
Forexample,considerthetree:
Deletingnode4yieldstwotreeswhosemembernodesare{5}and{1,2,3,6,7}.Thelargerofthesetwotreeshasfivenodes,thusthebalanceofnode4isfive.Deletingnode1yieldsaforestofthreetreesofequalsize:
{2,6},{3,7},and{4,5}.Eachofthesetreeshastwonodes,sothebalanceofnode1istwo.
Foreachinputtree,calculatethenodethathastheminimumbalance.Ifmultiplenodeshaveequalbalance,outputtheonewiththelowestnumber.
Input
Thefirstlineofinputcontainsasingleintegert(1<=t<=20),thenumberoftestcases.ThefirstlineofeachtestcasecontainsanintegerN(1<=N<=20,000),thenumberofcongruence.ThenextN-1lineseachcontainstwospace-separatednodenumbersthataretheendpointsofanedgeinthetree.Noedgewillbelistedtwice,andalledgeswillbelisted.
Output
Foreachtestcase,printalinecontainingtwointegers,thenumberofthenodewithminimumbalanceandthebalanceofthatnode.
SampleInput
1
7
26
12
14
45
37
31
SampleOutput
12
Source
POJMonthly--2004.05.15IOI2003sampletask
[Submit] [GoBack] [Status] [Discuss]
HomePage
GoBack
Totop
AllRightsReserved2003-2007YingFuchen,XuPengcheng,XieDi
Anypr
CountingBlack
TimeLimit:
1000MS
MemoryLimit:
10000K
TotalSubmissions:
6990
Accepted:
4448
Description
Thereisaboardwith100*100gridsasshownbelow.Theleft-topgirdisdenotedas(1,1)andtheright-bottomgridis(100,100).
Wemayapplythreecommandstotheboard:
1.WHITEx,y,L//Paintawhitesquareontheboard,
//thesquareisdefinedbyleft-topgrid(x,y)
//andright-bottomgrid(x+L-1,y+L-1)
2.BLACKx,y,L//Paintablacksquareontheboard,
//thesquareisdefinedbyleft-topgrid(x,y)
//andright-bottomgrid(x+L-1,y+L-1)
3.TESTx,y,L//Askforthenumberofblackgrids
//inthesquare(x,y)-(x+L-1,y+L-1)
Inthebeginning,allthegridsontheboardarewhite.Weapplyaseriesofcommandstotheboard.YourtaskistowriteaprogramtogivethenumbersofblackgridswithinarequiredregionwhenaTESTcommandisapplied.
Input
Thefirstlineoftheinputisanintegert(1<=t<=100),representingthenumberofcommands.Ineachofthefollowinglines,thereisacommand.Assumeallthecommandsarelegalwhichmeansthattheywon'ttrytopaint/testthegridsoutsidetheboard.
Output
ForeachTESTcommand,printalinewiththenumberofblackgridsintherequiredregion.
SampleInput
5
BLACK112
BLACK222
TEST113
WHITE211
TEST113
SampleOutput
7
6
Source
POJMonthly--2004.05.15LiuRujia@POJ
[Submit] [GoBack] [Status] [Discuss]
HomePage
GoBack
Totop
AllRightsReserved2003-2007YingFuchen,XuPengcheng,XieDi
Anyproblem,Please
DistanceonChessboard
TimeLimit:
1000MS
MemoryLimit:
10000K
TotalSubmissions:
16356
Accepted:
5719
Description
国际象棋的棋盘是黑白相间的8*8的方格,棋子放在格子中间。
如下图所示:
王、后、车、象的走子规则如下:
∙王:
横、直、斜都可以走,但每步限走一格。
∙后:
横、直、斜都可以走,每步格数不受限制。
∙车:
横、竖均可以走,不能斜走,格数不限。
∙象:
只能斜走,格数不限。
写一个程序,给定起始位置和目标位置,计算王、后、车、象从起始位置走到目标位置所需的最少步数。
Input
第一行是测试数据的组数t(0<=t<=20)。
以下每行是一组测试数据,每组包括棋盘上的两个位置,第一个是起始位置,第二个是目标位置。
位置用"字母-数字"的形式表示,字母从"a"到"h",数字从"1"到"8"。
Output
对输入的每组测试数据,输出王、后、车、象所需的最少步数。
如果无法到达,就输出"Inf".
SampleInput
2
a1c3
f5f8
SampleOutput
2121
311Inf
Source
POJMonthly--2004.05.15LiuRujia@POJ
[Submit] [GoBack] [Status] [Discuss]
HomePage
GoBack
Totop
AllRightsReserved2003-2007YingFuchen,XuPengcheng,XieDi
Anyproblem,PleaseContact
Eva'sProblem
TimeLimit:
1000MS
MemoryLimit:
10000K
TotalSubmissions:
12313
Accepted:
7497
Description
Eva的家庭作业里有很多数列填空练习。
填空练习的要求是:
已知数列的前四项,填出第五项。
因为已经知道这些数列只可能是等差或等比数列,她决定写一个程序来完成这些练习。
Input
第一行是数列的数目t(0<=t<=20)。
以下每行均包含四个整数,表示数列的前四项。
约定数列的前五项均为不大于10^5的自然数,等比数列的比值也是自然数。
Output
对输入的每个数列,输出它的前五项。
SampleInput
2
1234
1248
SampleOutput
12345
124816
Source
POJMonthly--2004.05.15Null
[Submit] [GoBack] [Status] [Discuss]
HomePage
GoBack
Totop
AllRightsReserved2003-2007YingFuchen,XuPengcheng,XieDi
Anyproblem,PleaseContact
Frogs'Neighborhood
TimeLimit:
5000MS
MemoryLimit:
10000K
TotalSubmissions:
2985
Accepted:
1242
SpecialJudge
Description
未名湖附近共有N个大小湖泊L1,L2,...,Ln(其中包括未名湖),每个湖泊Li里住着一只青蛙Fi(1≤i≤N)。
如果湖泊Li和Lj之间有水路相连,则青蛙Fi和Fj互称为邻居。
现在已知每只青蛙的邻居数目x1,x2,...,xn,请你给出每两个湖泊之间的相连关系。
Input
第一行是测试数据的组数T(0≤T≤20)。
每组数据包括两行,第一行是整数N(2Output
对输入的每组测试数据,如果不存在可能的相连关系,输出"NO"。
否则输出"YES",并用N×N的矩阵表示湖泊间的相邻关系,即如果湖泊i与湖泊j之间有水路相连,则第i行的第j个数字为1,否则为0。
每两个数字之间输出一个空格。
如果存在多种可能,只需给出一种符合条件的情形。
相邻两组测试数据之间输出一个空行。
SampleInput
3
7
4315421
6
431420
6
231121
SampleOutput
YES
0101101
1001100
0001000
1110110
1101010
0001100
1000000
NO
YES
010010
100110
000001
010000
110000
001000
Source
POJMonthly--2004.05.15Alcyone@pku
[Submit] [GoBack] [Status] [Discuss]
HomePage
GoBack
Totop
AllRightsReserved2003-2007YingFuchen,XuPengcheng,XieDi
PrincessFroG
TimeLimit:
1000MS
MemoryLimit:
65536K
TotalSubmissions:
1115
Accepted:
464
Description
Long,longagotherewasamonsterlivedinAdventureCastleofMagic.OnedayhesawthattheprinceInfanteConcordandhiswifePrincessCharmwerelivingsosweetalife.Couldn'thelpbecomingjealous,heusedhispowerfulmagictoturntheprincetoanuglyfrog.Thebraveandsmartprincessmadeuphermindtorescueherhusband.Afterovercomedthousandsofdifficultiesandchallenges,shefinallyarrivedattheAdventureCastleofMagic.Whenshesawherdearesthandsomehusbandhadbecomeanuglyandawfulfrogbythecurseofthemonster,herheartalmostbroken.Themonstergaveheraveryhardpuzzleasaconditiontoexchangetheprince.Theprincesswasrequiredtochoosetherightonesfromsomegivenropes.Arightropemeansthattheropewouldn'tmakeaknotbypullingupitstwoends.Iftheprincesschosealltherightones,thecursewoulddisappearandthepricewouldberescued,otherwisehewouldbestrangledtodeath.Inordertorescueherhusband,withouthesitation,theprincessacceptedthechallenge.
Herearetwoexampleropes.Figure_1isarightropewhileFigure_2isnotarightrope:
Figure_1
Input
Thefirstlineoftheinputisanintegert(1<=t<=20),representingthenumberofropes.Eachofthefollowinglinesdescribesarope.
Wedescribetheropebypointingoutthecr