您好,欢迎访问三七文档
当前位置:首页 > 财经/贸易 > 资产评估/会计 > 北京大学ACM国际大学生程序设计竞赛课件1
问题求解与程序设计李文新2004.2-6问题求解与程序设计课程内容授课方式成绩评定进度安排信息学奥赛简介ACM大学生程序设计竞赛简介简单题–较难题作业课程内容信息学奥赛及ACM比赛题目•透过比赛题目,提高分析问题和应用计算机编程解决问题的能力•为北大ACM代表队培养后备人才授课方式每周二9-10,电教125集中授课•教师讲授•学生分组讨论,全班讨论•学生讲授每周两小时上机,时间地点待定•网上计时做题成绩评定总则:做够一定数量的题目可以及格想要优秀则需要在班里排名前10%期中20%+期末40%+作业30%+个人表现10%作业:每周2-4题,每月出1题进度安排1-2简单题3模拟题4-5图论题6组合数学题7几何题8-9动态规划题10-11搜索题12-14综合信息学奥赛简介对象组织形式考试方式题目及评分我国的情况ACM竞赛简介对象组织形式考试方式题目及评分我国及我校的情况ACM竞赛样题一个最简单的ProblemSimple.docIOI2002试题乌托邦utopia.doc例题:ioi2002day1task2utopia问题描述–utopia.doc问题分析•两个彼此独立的序列•对于一维问题求解•符号序列si•数值序列xi•对xi重新排列并加相应的正负号,使其按新顺序逐一相加后,等到符号si.例题:ioi2002day1task2utopia--问题的解Definition–alternatingsequenceAsequenceofnon-zerointegersX=(xa,xa+1,…,xb,),a≤bisanalternatingsequenceif1)|xa||xa+1|…|xb|,and2)foralli,ai≤b,thesignofxiisdifferentfromthesignofxi-1.Here,|xa|istheabsolutevalueofxa.例题:ioi2002day1task2utopia--问题的解Lemma1.LetX=(xa,xa+1,…,xb)beanalternatingsequence.Thesignofxbisequaltothesignof∑a≤i≤bxi,thetotalsumofelementsinX.例题:ioi2002day1task2utopia--问题的解ProofAssume:•xbispositive•numberofelementsinXisevenThen:xa+xa+1,xa+2+xa+3,…,xb-1+xbareallpositive,thusthetotalsum∑a≤i≤bxiispositive.例题:ioi2002day1task2utopia--问题的解Example1.(-1,+2,-5,+6)=(-1+2)+(-5+6)=+2whichispositive.Example2.(+3,-4,+5,-6,+7)=(+3)+(-4+5)+(-6+7)=+5,whichisalsopositive.例题:ioi2002day1task2utopia--问题的解Theorem1.LetX=(xa,xa+1,…,xb),a≤bbeanalternatingsequence,andletS=(sa,sa+1,…,sb),a≤bbeasequenceofsigns.Ifthesignofxbisequaltosb,thenthereexistsasequenceX’=(xia,xia+1,…,xib)suchthat1){xa,xa+1,…,xb}={xia,xia+1,…,xib},and2)X’isvalidwithrespecttoS.例题:ioi2002day1task2utopia--问题的解ProofTheproofisbyinductiononthenumberofkofelementsinX.Whenk=1,itiseasytoseethatX’=XisavalidsequencewithrespecttoS.Nowweassumethatk≥2.WeletS1=S-sb,thatis,S1=(sa,sa+1,…,sb-1).Case1.Thesignofsb-1isequaltoxb,LetX1=X-xa,thatis,X1=(xa+1,xa+2,…,xb).Case2.Thesignofsb-1isequaltoxb-1,LetX1=X-xb,thatis,X1=(xa,xa+1,…,xb-1).例题:ioi2002day1task2utopia--问题的解Example3.X=(-4,+5,-7,+8),S=(+,-,-,+),wehaveS1=(+,-,-),X1=(-4,+5,-7),S2=(+,-),X2=(+5,-7),S3=(+),X3=(+5).Thus,X3’=(+5),X2’=(+5,-7),X1’=(+5,-7,-4),X’=(+5,-7,-4,+8).例题:ioi2002day1task2utopia--问题的解Example4.X=(-1,+2,-3)andS=(-,-,-),S1=(-,-),X1=(+2,-3),S2=(-),X2=(-3).Thus,X2’=(-3),X1’=(-3,+2),X’=(-3,+2,-1).例题:ioi2002day1task2utopia--问题的解AlgorithmofutopiaStep1.//readinput1.1readN;1.2read2NcodenumbersandpartitionthemintoAandBsuchthat|A|=|B|;1.3readasequenceofregionsR=(r1,r2,…,rN);例题:ioi2002day1task2utopia--问题的解Step2.//findx-coordinatesofcodepairs2.1findasequenceofsignsS=(s1,s2,…,sN)suchthatforallj,1≤j≤N,sj=‘+’ifrj=1,4;otherwisesj=‘-’.2.2findanalternatingsequenceX=(x1,x2,…,xN)fromAsuchthatthesignofxNisequaltosN.2.3givenXandS,findavalidsequenceX’=(xi1,xi2,…,xiN)w.r.tSaccordingtotheproofofTheorem1.例题:ioi2002day1task2utopia--问题的解Step3.//findy-coordinatesofcodepairs3.1findasequenceofsignsS=(s1,s2,…,sN)suchthatforallj,1≤j≤N,sj=‘+’ifrj=1,2;otherwisesj=‘-’.3.2findanalternatingsequenceY=(y1,y2,…,yN)fromBsuchthatthesignofyNisequaltosN.3.3givenYandS,findavalidsequenceY’=(yi1,yi2,…,yiN)w.r.tSaccordingtotheproofofTheorem1.例题:ioi2002day1task2utopia--问题的解Step4.//writeoutputprint(xi1,yi1),(xi2,yi2),…,(xiN,yiN).例题:ioi2002day1task2utopia--问题的解Theorem2AlgorithmUtopiaiscorrect,anditsrunningtimeisO(NlogN).ProofThecorrectnessofthealgorithmismainlyduetoTheorem1.ThecomplexityofeachstepexceptStep2.2and3.2osO(N),whereStep2.2and3.2requireO(NlogN)timeforsorting.例题:ioi2002day1task2utopia--问题的解TestingdataNoSize,nmDescription1N=4Example22N=10Keyvalue:1~20,Circularplanesweep3N=10Keyvalue:Startingfrom30,step1or2,scramled………25N=10000Keyvalue:Startingfrom80000~99999,scambled例题:ioi2002day1task2utopia--问题的解Grading4*25=100例题:ioi2002day1task2utopia--问题的解考试答题情况TaskSubmissionNo.offullscoresAverageUptopia209716.21作业用C04+学号建立帐户完成1005,1006题
本文标题:北京大学ACM国际大学生程序设计竞赛课件1
链接地址:https://www.777doc.com/doc-3832667 .html