noip 2012 提高组 解题报告.docx_第1页
noip 2012 提高组 解题报告.docx_第2页
noip 2012 提高组 解题报告.docx_第3页
noip 2012 提高组 解题报告.docx_第4页
noip 2012 提高组 解题报告.docx_第5页
已阅读5页,还剩14页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

noip 2012 提高组 解题报告 Vigenre密码模拟注意大小写vari,l,t:longint;a:Array0.1000 of longint;s:string;ch:char;begin readln(s); l:=length(s); for i:=1 to l do if ord(si)=97 then ai:=ord(si)-96 else ai:=ord(si)-64; a0:=al; read(ch); i:=1; t:=ord(ch); while (t64)and(t124) do begin if t9 do begin gl+1:=gl+1+gl div 10; gl:=gl mod 10; inc(l); end; if gl=0 then dec(l);end;procedure gj2;varj:longint;begin for j:=l downto 1 do begin gj-1:=gj-1+(gj mod cn)*10; gj:=gj div cn; end; while gl=0 do dec(l);end;procedure sort(l,r:longint);vari,j,x,y:longint;begin i:=l; j:=r; x:=a(l+r) div 2; repeat while aix do inc(i); while xj) then begin y:=ai; ai:=aj; aj:=y; y:=bi; bi:=bj; bj:=y; y:=ci; ci:=cj; cj:=y; inc(i); dec(j); end; until (ij); if lj then sort(l,j); if ir then sort(i,r);end;begin readln(n); readln(b0,c0); for i:=1 to n do begin read(bi,ci); ai:=bi*ci; end; sort(1,n); l:=1; g1:=b0; for i:=1 to n-1 do gj1; gj2; for i:=l downto 1 do write(gi); writeln;end.开车旅行链表+倍增1. 按城市高度递增顺序排序,放到链表中2. 从第一个城市起,找离它最近和次近的城市,记录下来3. 填每个点向前走20步(压缩后的一步,即A走一次B走一次);4. 倍增:处理处每个点向前走2j步能到的城市和到这个城市A,B需要走的距离方程:fI,j=ffI,j-1,j-1; aI,j=aI,j-1+afI,j-1,j-1; bI,j=bI,j-1+bfI,j-1,j-15. 依据s,x判断能走到哪个城市及A,B走过距离program day13;label 1;typepoint=rec;rec=record da:longint; la,ne:point;end;vari,n,m,t,s,top,j,k,ans,dk,lj:longint;h,a,mi,mmi,b:array0.100000 of int64;line:array0.100000 of point;fa,na,nb:array0.100000,-2.17 of int64;p,q:point;bo:array0.100000 of boolean;re:real;la,lb,x:int64;flag:boolean;procedure sort(l,r:longint);vari,j,x,y:longint;begin x:=h(l+r) div 2; i:=l; j:=r; repeat while hix do inc(i); while xj) then begin y:=hi; hi:=hj; hj:=y; y:=ai; ai:=aj; aj:=y; inc(i); dec(j); end; until ij; if lj then sort(l,j); if i=la+lb+nak,j+nbk,j)and(fak,j0) do inc(j); if (xla+lb+nak,j+nbk,j)and(j=0) then flag:=false; if fak,0=0 then flag:=false; la:=la+nak,j-1; lb:=lb+nbk,j-1; k:=fak,j-1; end; if (mmik0)and(la+lb+abs(bmmik-bk)=x) then la:=la+abs(bmmik-bk);end;begin readln(n); for i:=1 to n do begin read(hi); ai:=i; end; b:=h; sort(1,n); new(linea1); linea1.la:=nil; linea1.da:=a1; for i:=2 to n do begin new(lineai); lineai.la:=lineai-1; lineai.da:=ai; lineai-1.ne:=lineai; end; linean.ne:=nil; for i:=1 to n do begin p:=linei.la; q:=linei.ne; if (p=nil)and(q=nil) then goto 1; if (qnil)and(p=nil)or(bi-bp.dabq.da-bi) then begin mii:=q.da; q:=q.ne; if (p=nil)and(q=nil) then goto 1; if (qnil)and(p=nil)or(bi-bp.dabq.da-bi) then mmii:=q.da else mmii:=p.da; end else begin mii:=p.da; p:=p.la; if (p=nil)and(q=nil) then goto 1; if (pnil)and(q=nil)or(bq.da-bi=bi-bp.da) then mmii:=p.da else mmii:=q.da; end;1: if linei.lanil then linei.la.ne:=linei.ne; if linei.nenil then linei.ne.la:=linei.la; linei:=nil; end; for i:=1 to n do if mmii0 then begin t:=mmii; if mit0 then begin nbi,0:=abs(bt-bmit); nai,0:=abs(bi-bt); end; fai,0:=mit; end; for i:=1 to n do fai,-1:=i; for j:=1 to 17 do for i:=1 to n do begin fai,j:=fafai,j-1,j-1; if fai,j0 then begin nai,j:=nai,j-1+nafai,j-1,j-1; nbi,j:=nbi,j-1+nbfai,j-1,j-1; end; end; read(x); re:=10000000000; for s:=1 to n do begin deal; if (lb0)and(rela/lb) then begin re:=la/lb; ans:=s; end; end; writeln(ans); read(m); for i:=1 to m do begin read(s,x); deal; writeln(la, ,lb); end;end.同余方程扩展欧几里得依据gcd(a,b)=gcd(b,a mod b);设ax1+by1=gcd(a,b)=1则bx2+(a mod b)y2=gcd(b,a mod b);ax1+by1=bx2+(a mod b)y2;ax1+by1=bx2+(a-a/b*b)y2=ay2+bx2-(a/b)*by2;根据恒等定理得:x1=y2; y1=x2-a/b*y2;vara,b,n,m,t:longint;procedure e(a,b:longint;var x,y:longint);begin if b=0 then begin x:=1; y:=0; exit; end else begin e(b,a mod b,x,y); t:=x; x:=y; y:=t-(a div b)*y; end;end;begin read(a,b); e(a,b,n,m); if nnow then for i:=now+1 to k do begin inc(sumsi,di); dec(sumti+1,di); end else for i:=k+1 to now do begin dec(sumsi,di); inc(sumti+1,di); end; now:=k; ssum:=0; for i:=1 to n do begin inc(ssum,sumi); if ssumroomi then begin flag:=false; break; end; end; if flag then l:=k+1 else r:=k; until l=r; if (k=m)and(flag) then print; writeln(-1); write(l);end;begin init; work;end.疫情控制DFS+倍增+二分答案+贪心1. dfs找出倍增序列2. 二分答案:在给定时间ans内1) 对于某个军队:若能到达首都,记下到达首都后的剩余时间 若不能,让它尽可能的向首都走2)dfs找出来哪个边境城市需要军队驻守,则需要走到从这个边境城市出发向首都走所需经过的最后一个点,按这个点到首都距离从大到小排序,若这个点有军队通过它进入首都,选择剩余时间不能走到这个点且经过这个点能到首都的军队。否则从到达首都的所有军队中选一个剩余时间最小的军队驻守。label 1;vari,j,k,n,m,f1,t,min,max,top,ans,cans,mi,q,dk,c1,cm1:longint;f,d,r,e,bo,s,a,c:array0.100000 of longint;fa,lx:array0.50000,0.16 of longint;cm:array0.1,0.50000 of longint;boo,need,had,have:array0.50000 of boolean;flag:boolean;procedure csort(l,r:longint);varii,ij,xx,xy:longint;begin xx:=c(l+r) div 2; ii:=l; ij:=r; repeat while (ciixx)and(iir) do inc(ii); while (xxl) do dec(ij); if not (iiij) then begin xy:=cii; cii:=cij; cij:=xy; inc(ii); dec(ij); end; until iiij; if lij then csort(l,ij); if iir then csort(ii,r);end;procedure dfs(i,T1:longint);varj,k:longint;begin if boii then begin j:=1; i:=ctop; while top-j0 do begin inc(fai,0); fai,fai,0:=ctop-j; lxi,fai,0:=dctop-dctop-j; j:=j*2; end; exit; end; di:=t; boi:=t1; inc(top); ctop:=i; for j:=fi to fi+1-1 do begin t:=t+aj; dfs(ej,boi); t:=t-aj; end; ctop:=0; dec(top);end;procedure sort(l,r:longint);vari,j,x,y:longint;begin x:=s(l+r) div 2; i:=l; j:=r; repeat while six do inc(i); while xj) then begin y:=ai; ai:=aj; aj:=y; y:=si; si:=sj; sj:=y; y:=ei; ei:=ej; ej:=y; inc(i); dec(j); end; until ij; if lj then sort(l,j); if ir then sort(i,r);end;procedure ssort(l,r:longint);varii,ij,xx,xy:longint;begin xx:=a(l+r) div 2; ii:=l; ij:=r; repeat while (aiixx)and(iir) do inc(ii); while (xxl) do dec(ij); if not (iiij) then begin xy:=aii; aii:=aij; aij:=xy; xy:=sii; sii:=sij; sij:=xy; xy:=eii; eii:=eij; eij:=xy; inc(ii); dec(ij); end; until iiij; if lij then ssort(l,ij); if iir then ssort(ii,r);end;procedure init;begin read(n); m:=n-1; for i:=1 to m do readln(si,ei,ai); for i:=m+1 to 2*m do begin si:=ei-m; ei:=si-m; ai:=ai-m; end; for i:=1 to n do boi:=i; sort(1,2*m); f1:=1; f1:=1; for i:=1 to 2*m+1 do if sif1 then begin inc(f1); ff1:=i; end; q:=f2-f1; ssort(1,q); bo1:=-1; c1:=1; top:=1; for k:=f1 to f2-1 do begin dek:=t+ak; t:=t+ak; dfs(ek,-ek); t:=t-ak; end; read(m); for i:=1 to m do read(ri); if mq then writeln(-1); for i:=1 to n do for j:=1 to fai,0 do if max=dri then begin if (cm0,-bori=ans-dri)and(ans-dri=lxk,j)and(lxk,j+10) do begin dk:=fak,j; inc(j); end; if (j=1)and(canslxk,j) then begin havedk:=true; flag:=false; end else begin cans:=cans-(dk-ddk); k:=dk; end; end; end; boo1:=true; for k:=f1 to f2-1 do if not haveekthen ddfs(ek); for i:=1 to q do if (needei)and(cm1,ei0) then begin hadcm1,ei:=true; needei:=false; end; for i:=1 to m do if not had

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论