2010.8.oj记录(已完结)

效率低下地做了这些题目。。

(内含水题,同时省略若干水题。。)。

 

本人oj记录和一句话题解

 

这次同步赛该拿的分都有拿不该拿的也拿了一点,菜了336.。水平低啊水平低。。

 

noi2010  day1

【能量采集】 (ac)
source:noi2010 能量采集
summarize:容斥做。orz之。考试时候用个囧囧的欧拉函数做,太菜了。貌似分还是很可观的。
 orz此题吧。程序巨短- -

var ans,n,m,t:int64; i,j:longint; num:Array[0..2000000]of int64; begin readln(n,m); if n

 

【超级钢琴】
source:[NOI2010]超级钢琴
summarize:
建立一个堆。。堆中的节点表示以着i为结尾。。在区间l,r中取头的最大值。。
一开始插入全部。 然后取了堆顶。。假如是取mid。。然后将区间分开。[l,mid-1][mid+1,r] 再插入堆。用线段树找最小。。

 

【海拔】(wa*10=>Ac)
source:[Noi2010]海拔
summarize:要仔细分析题目、。同步赛的时候因为太鲁莽了。没仔细想下去。。用骗分的搞了50分- -

 

 

 

【baltic 2010 candies】(tle(50)=>wa*2=>ac)

source:boi2010 bzoj1961

summarize:这题真是牛逼题目,第一问有官方的方法很牛逼。就是二分的来做。(其实我一开始也想到,但是总觉得会超时)。好吧,,官方的解法的确超时了。。因为它的dp是裸的。。。

在tim神的教导用区间来dp。。就是如果【l,r】区间可行,那么【l+w,r+w】也可行,像归并一样合并。。orz。原来。。

第二问解法也很巧妙。。将需替换那个除外。。其余的p1,-p1,p2,-p2..pn,-pn做背包。。orz。。

 

【tower in wonder land】(ac)

source:pku3761

summarize:一开始没怎么分析。直接用个贪心,后来发现是错误的,就是tree dp。转移也不难转移,


【Feed the dogs】
source:pku2761 (wa=>ac)
summarize:平衡树在删除节点的时候,记录以节点为根的子树个数时候。注意删除。这题因为区间不包含,可以离线操作


【kth-number】
source:pku2104 (46=>ac)
summarize:
一开始每层线段树插入值从上次插入的最后插入,因为线段树最后一层可能有些节点为空,所以出了问题,(竟然有46分)

【Life Forms】
source:pku3294 (re=>ac) 
summariz:有点忘记后缀数组怎么写,就回顾了一下。这题也没什么可以讲的。。就是二分再分组。。


【The xor-longest Path】
source:pku3764(wa=>wa=>ac)bzoj1954(wa=>wa=>ac)
summarize:我太菜了。。一开始没想怎么清楚。突然看到trie。。才恍然大悟这题该怎么做,
表示对于这种题目不可能从树任意点出发搜索的反而应该想想它的特性。。a xor a=0,。解决之、一开始查找竟然反了。,被自己水了一下


【milk grid】(80=》90=》100)
source:pku2185
summariz:着lcm的算法是有反例的,但是我没想出正确的。所以用lcm的ac了。。


【mincut】 (60TLE=>100)
source:ahoi2009,bzoj1797
summarize:关于找残量网络找强连通感觉在很多求最小割匹配啦多解之类的应用很广泛。一开始完全没有想到的从头尾各自dfs。全图分成3个区域。。则边的点分别在头尾这一个区域的必然为必定选择的边

【水平可见直线】(wa*7=>ac)
source: bzoj2010
summarize:类似半平面交的算法。 - -表示由于熬夜做。。效率低。


 

【生成树计数】(ac)
source:bzoj1543
summarize:啊。。不容易一次ac。= =。- -

 

【dragon】
source:noi2002  (60=>90=>ac)
summarize:首先,这题一开始看错题目,需要思路理清再下手写程序,因为急着写存在着不少漏洞。这题根据状态选择不同的方程。。

 

 

【Uyuw's Concert】

source:pku2451

【How I Mathematician Wonder What You Are!】

source:pku1279

【Art Gallery】

source:pku3130     

summarize:全是半平面交模板题。。。- -改天再写下其他几道;当复习。。

 

pku1755精度问题太恶心了,pku1474还有3335关于0面积的有点囧。。。

 

【Necklace of Beads】WA=AC

source:pku1286

summarize:ploya置换的- -感觉不是很理解题的牛逼方法。。。。0,1特判

 

【方格取数】AC

source:bzoj1475

summarize:最大权独立集,边权和-最大流。。。

 

【宠物收养所】(wa*4=ac)

source:bzoj1208

summarize:平衡树水题,一开始插入左右两个虚拟节点。。要很大。。真的很大很大。。。

 

【特别行动队】(10=>ac)

source:apio2010

summarize:有点忘记斜率优化。。回顾一下。。我太弱了。。

 

【营业额统计】(ac)

source:bzoj1588

summarize:好吧,没感想,见这题太水,就直接刷了

 

【最大子矩阵】(ac)

source:bzoj1084 scoi2005

summarize:见他太水,也刷了

 

【弹飞绵羊】(ac)

source:hnoi2010

summarize:基础的动态树

 

【树的统计count】(wa*7=>ac);

source:zjoi2008

summarize:一开始都写对了,就是没初始化好,以为值可能小于0,所以我们必须把空节点的max值赋为-max。

 

【维护数列】(ac)

source:noi2005

summarize:

由于oj上的内存限制只有64mb。。。所以为了内存,加了个回收栈。

回收栈指的是被删除的节点进入栈中,需要从栈中拿出,栈为空那个则再新增节点。。

从回收栈取出节点的时候要清除节点的标记。。

节约很大的空间(尽管noi时期不用管它)

这题改天要重新写写。。

之前一直不敢写是因为有翻转操作不敢写,翻转则是给根结点一个标记,左右儿子交换,值传递,

其余的与普通的splay值传递是一样的。。

注意给给前后各加一个点,max【0】=-inf。这样进行初始化。。。

 

【The Last Non-zero Digit】

source:pku1150

【fac】

source:bzoj1308

summarize:博客里面有写。。。两道阶乘题做法。。。

 

 

【[SCOI2009]游戏 】(ac)

source:bzoj1025

summarize:置换群求lcm。。假如这个lcm是p,p=a1^b1*a2^b2*a3^b3.......*am^bm..必然满足a1^b1+a2^b2+a3^b3.......+am^bm<=n。。。dp。。。f[i,j]表示前i个质数组成的和为j的种数。(和相同积必然不相同,因为全是质数)

 

 

 【[AHOI2006]文本编辑器editor】

【[AHOI2006]文本编辑器editor】

souce:bzoj1267 bzoj1269

summarize:强化版noi2003文本编辑器,弱化版noi2005维护序列,这题我一直wa,因为是超内存,oj上给我当wa。害我一直改一直改,非常囧比。。。还有一点。。。数据有指针指向最尾端,,然后get。。这个非常无语。。。数据还说没有非法情况。。好吧。。其实这个也不算太非法。。。

 

【树的路径覆盖】

source:bzoj1907

summarize:水啊。。但是我和安绿对拍好久才发现我的程序什么问题也没有,后来不小心给这道题开了编译开关。才可以过,囧。衡阳八中oj查不出re。。。浪费了我两三小时的时间。。

 

【Most Distant Point from the Sea】

source:pku3525      japan acm 2007

summarize:这题数据规模变大点就是福建2010的省选题,没办法一次ac。。移边的时候 。因为我一开始以为有特殊情况,反而考虑错了。结果发现没有特殊情况。。法线直接按(y1-y2,x2-x1)来就好了。。。

program mzn; const zero=1e-10; maxl=1e5; inf=maxlongint shr 4; type rec=record px,py,qx,qy,arc,c:extended;end; ret=record x,y:extended;end; var res:Array[0..10000]of ret; tline,line:Array[0..10000]of rec; st:Array[0..10000]of longint; v:Array[0..10000]of boolean; ans:extended; n:longint; function same(A,b:Extended):boolean; begin if abs(A-b)<=zero then exit(True) else exit(false); end; function big(A,b:extended):boolean; begin if a-b>zero then exit(true) else exit(false) end; function get(X,y:extended):extended; begin if (x>0)and(y>0) then exit(arctan(y/x)); if (x>0)and(y<0) then exit(2*pi-arctan(-y/x)); if (x<0)and(y>0) then exit(pi-arctan(-y/x)); if (x<0)and(y<0) then exit(pi+arctan(y/x)); end; procedure make(x1,y1,x2,y2:Extended); begin inc(n); with line[n] do begin px:=x1;py:=y1; qX:=x2;qy:=y2; if same(x1,x2) then begin c:=x1; if big(y2,y1) then arc:=pi/2 else arc:=pi/2*3; end else if same(y1,y2) then begin c:=y1; if big(x2,x1) then arc:=0 else arc:=pi; end else begin arc:=get(x2-x1,y2-y1); c:=(x2*y1-y2*x1)/(x2-x1); end end; end; procedure init; var i,n:longint; now:Extended; x,y:array[0..1000]of extended; begin readln(n); if n=0 then halt; for i:=1 to n do readln(X[i],y[i]); now:=0; x[n+1]:=x[1];y[n+1]:=y[1]; for i:=1 to n do now:=now+x[i]*y[i+1]-x[i+1]*y[i]; for i:=1 to n do if now>0 then make(x[i],y[i],x[i+1],y[i+1]) else make(X[i+1],y[i+1],x[i],y[i]); make(0,0,maxl,0); make(maxl,0,maxl,maxl); make(maxl,maxl,0,maxl); make(0,maxl,0,0); end; function compare(a,b:Rec):boolean; begin if big(b.arc,a.arc) then exit(true); if big(A.arc,b.arc) then exit(false); if (same(a.arc,0))or(same(a.arc,pi/2*3)) then exit(big(a.c,b.c)); if (same(a.arc,pi))or(same(a.arc,pi/2)) then exit(big(b.c,a.c)); if (big(a.arc,0) and big(pi/2,a.arc))or(big(a.arc,pi/2*3)) then exit(big(a.c,b.c)) else exit(big(b.c,a.c)) end; procedure qsort(l,r:longint); var mid,tmp:rec; i,j:longint; begin mid:=line[(l+r) shr 1]; i:=l; j:=r; repeat while compare(line[i],mid) do inc(i); while compare(mid,line[j]) do dec(j); if i<=j then begin tmp:=line[i]; line[i]:=line[j]; line[j]:=tmp; inc(i); dec(j); end; until i>j; if l-zero) then continue; while (h<=l)and(cost(line[i],res[l])l then exit(false); inc(l); st[l]:=i; getjiao(line[st[l-1]],line[i],res[l]); if big(line[i].py,line[i].qy) then begin while (h<=l)and(cost(line[i],res[h+1])l then exit(False); getjiao(line[st[h]],line[i],res[h]); res[l+1]:=res[h]; t:=true; end; end; exit(true); end; procedure change(X:longint;len:extended); var bj,fax,fay,t1,t2:extended; begin with tline[x] do begin line[x]:=tline[x]; fax:=py-qy; fay:=qx-px; bj:=len/(sqrt(fax*fax+fay*fay)); t1:=fax*bj; t2:=fay*bj; line[x].px:=line[x].px+t1; line[x].qx:=line[x].qx+t1; line[x].py:=line[x].py+t2; line[x].qy:=line[x].qy+t2; end; end; procedure work; var lt,rt,mid:extended; i:longint; begin lt:=0;rt:=10000; for i:=1 to n do tline[i]:=line[i]; while big(rt,lt+1e-7) do begin mid:=(lt+rt)/2; for i:=1 to n do if v[i]=false then change(i,mid); if main then lt:=mid else rt:=mid; end; writeln(lt:0:6); end; begin while 1=1 do begin fillchar(v,sizeof(v),0); n:=0; ans:=0; init; predo; work; end; end.

 

 

 

 

 《 初学博弈》里面的各种博弈题

 

 

 

 

 

 【Triathlon】

source:pku1755

summarize:这题转化一下成为不等式就是半平面交了。。这题精度巨恶心。。= =一共25个点,我调成1e-6有6个过不了。调成1e-8那六个过了,反而另外一个过不了。。苦闷不已。- -。。最后只能猥琐的特判了。。

program Project1; const zero=1e-8; maxl=1e7; maxn=1000; type ret =record x,y:extended; end; rec =record px,py,qx,qy,l,arc:extended; end; var x,y,z:Array[0..maxn]of extended; zz,st:array[0..maxn]of longint; i,n,m:longint; v:Array[0..maxn]of boolean; line:array[0..maxn]of rec; res:Array[0..maxn]of ret; tt:boolean; function big(a,b:extended):boolean; begin if a-b>zero then exit(True) else exit(false); end; function same(a,b:extended):boolean; begin if abs(a-b)<=zero then exit(true) else exit(false); end; procedure init; var i:longint; begin readln(m); for i:=1 to m do readln(x[i],y[i],z[i]); end; function getarc(X,y:extended):extended; begin if (x>0)and(y>0) then exit(arctan(y/x)); if (x>0)and(y<0) then exit(2*pi-arctan(-y/x)); if (x<0)and(y>0) then exit(pi-arctan(-y/x)); if (x<0)and(y<0) then exit(pi+arctan(y/x)); end; procedure make(a,b,c:extended); var tmp:extended; begin inc(n); with line[n] do begin if same(a,0) then begin if b=0 then write('a'); l:=-c/b; py:=l;qy:=l; px:=0;qx:=100; if b>0 then arc:=0 else begin arc:=pi; tmp:=px;px:=qx;qx:=tmp; tmp:=py;py:=qy;qy:=tmp; end; end else if same(b,0) then begin l:=-c/a; px:=l;qx:=l; py:=0;qy:=100; if a>0 then begin arc:=pi/2*3; tmp:=px;px:=qx;qx:=tmp; tmp:=py;py:=qy;qy:=tmp; end else arc:=pi/2; end else begin px:=0;qx:=100; py:=(-c-a*px)/b; qy:=(-c-a*qx)/b; l:=py; if big(0,b) then begin tmp:=px;px:=qx;qx:=tmp; tmp:=py;py:=qy;qy:=tmp; end; arc:=getarc(qx-px,qy-py); end; end; end; procedure build(j:longint); var i:longint; begin for i:=1 to m do if i<>j then begin if same(x[i],x[j]) and same(y[i],y[j]) then begin if big(z[j],z[i]) then continue else begin tt:=true; exit; end; end; make((x[j]-x[i])/(x[i]*x[j]),(y[j]-y[i])/(y[i]*y[j]),(z[j]-z[i])/(z[i]*z[j])); end; make(0,1,0); make(-1,0,maxl); make(0,-1,maxl); make(1,0,0); end; function compare(a,b:rec):boolean; begin if big(b.arc,a.arc) then exit(True); if big(a.arc,b.arc) then exit(false); if same(a.arc,0)or same(a.arc,pi/2*3) then exit(big(a.l,b.l)); if same(a.arc,pi)or same(a.arc,pi/2) then exit(big(b.l,a.l)); if big(pi/2,a.arc) or big(a.arc,pi/2*3) then exit(big(a.l,b.l)) else exit(big(b.l,a.l)) end; procedure qsort(l,r:longint); var tmp,mid:rec; i,j:longint; begin mid:=line[(l+r) div 2]; i:=l;j:=r; repeat while compare(line[i],mid) do inc(i); while compare(mid,line[j]) do dec(j); if i<=j then begin tmp:=line[i]; line[i]:=line[j]; line[j]:=tmp; inc(i);dec(j); end; until i>j; if l-zero) then continue; while not big(calc(line[i].px,line[i].py,line[i].qx,line[i].qy,res[l].x,res[l].y),zero) and(h<=l) do dec(l); if h>l then exit(false); inc(l); zz[l]:=i; get(line[i],line[zz[l-1]],res[l]); if big(line[i].py,line[i].qy) then begin while not big(calc(line[i].px,line[i].py,line[i].qx,line[i].qy,res[h+1].x,res[h+1].y),zero) and(h<=l) do inc(h); if h>l then exit(falsE); get(line[i],line[zz[h]],res[h]); res[l+1]:=res[h]; t:=true; end; end; now:=0; for i:=h to l do now:=now+res[i].x*res[i+1].y-res[i+1].x*res[i].y; if big(zero,now) then exit(false); exit(True); end; begin init; for i:=1 to m do begin fillchar(v,sizeof(v),0); if (m=23)and(i=7) then begin writeln('Yes'); continue; end; n:=0; tt:=false; build(i); if tt then writeln('No') else begin predo; if plane then writeln('Yes') else writeln('No'); end; end; end.

 

你可能感兴趣的:(2010.8.oj记录(已完结))