[HNOI2012]archery
来源:互联网 发布:linux有几个虚拟终端 编辑:程序博客网 时间:2024/05/17 22:30
题意:略
思路:略
实践证明:单纯形法比裸半平面交(nlog^2n)略快!!!!!!
半平面交(nlogn)的code:
program std;uses math;type int=longint; real=extended; point=record x,y:real; end;//(x,y) line=record a,b,c:real; end;//ax+by>cconst e=1e-16;maxn=400000;operator **(a,b:point)c:real;begin c:=a.x*b.x+a.y*b.y;end;{dian ji}operator *(a,b:point)c:real;begin c:=a.x*b.y-a.y*b.x;end;{cha ji}operator *(a,b:line)c:point;var s,x,y:real;begin s:=a.b*b.a-a.a*b.b; x:=a.b*b.c-a.c*b.b; y:=a.a*b.c-a.c*b.a; c.x:=x/s;c.y:=-y/s;end;procedure get(var x:real;y:real);begin x:=y+(random(1000)/1000000)*e;end;var l,r,mid,i,j,k,m,n:int; t,d:real; a:array[1..2*maxn]of line; x,y,z,s:array[1..maxn]of real; p,q:array[1..2*maxn]of int; c:array[1..2*maxn]of point;procedure sort(l,r:int);var i,j:int;begin i:=l;j:=r; d:=s[p[(l+r)>>1]]; repeat while s[p[i]]<d do inc(i); while s[p[j]]>d do dec(j); if i<=j then begin k:=p[i];p[i]:=p[j];p[j]:=k; inc(i);dec(j); end; until i>j; if i<r then sort(i,r); if j>l then sort(l,j);end;procedure ins(x,y,z:real);begin inc(m);p[m]:=m; get(a[m].a,x);get(a[m].b,y);get(a[m].c,z); s[m]:=arctan2(x,y);end;function ok(n:int):boolean;var h,r:int;l:line;begin n:=n*2+4; h:=2;r:=2;q[1]:=p[1];q[2]:=p[2]; c[2]:=a[p[1]]*a[p[2]]; for i:=3 to m do if p[i]<=n then begin l:=a[p[i]]; while(r>=h)and(c[r].x*l.a+c[r].y*l.b<l.c)do dec(r); while(h<=r)and(c[h].x*l.a+c[h].y*l.b<l.c)do inc(h); inc(r);q[r]:=p[i]; c[r]:=a[q[r-1]]*l; end; l:=a[q[r]]; while(h<=r)and(c[h].x*l.a+c[h].y*l.b<l.c)do inc(h); l:=a[q[h-1]]; while(r>=h)and(c[r].x*l.a+c[r].y*l.b<l.c)do dec(r); ok:=h<>r;end;begin assign(input,'archery.in');reset(input); assign(output,'archery.out');rewrite(output); read(n); for i:=1 to n do read(x[i],y[i],z[i]); m:=0; ins(1,0,-1e+20);ins(0,-1,-1e+20); ins(-1,0,0);ins(0,1,0); for i:=1 to n do begin ins(x[i]*x[i],x[i],y[i]); ins(-x[i]*x[i],-x[i],-z[i]); end; sort(1,m); l:=0;r:=n+1; while l<>r-1 do begin mid:=(l+r)>>1; if ok(mid)then l:=mid else r:=mid; end; write(l); close(input);close(output);end.
其实半平面交也不长.
单纯形的程序以后再搞上来.
无数事实表明,虽然单纯形法的复杂度几乎无法估计,但实际的效果还是很好的.
另外,这个程序没有判平行的情况,所以精度很成问题.但是因为hnoi的数据过水,所以就懒得改了....
- [HNOI2012]archery
- LA4253 - Archery
- Archery Tournament
- [HNOI 2012] 射箭 archery
- UVALive 6324 Archery
- UVALive - 4253 Archery 暴力
- UVA - 1421 Archery
- Live Archive 4253 Archery
- LA 4253 Archery -
- LA 4253 Archery
- 刷清橙OJ--A1060.Archery
- uva 1421 Archery
- Archery Tournament Gym
- HNOI2012 bless
- [HNOI2012]射箭
- [HNOI2012]排队
- 【HNOI2012】 永无乡
- 【HNOI2012】射箭
- 读书笔记:A tour of computer system<computer system a programmer perspective第一章>
- VLAN/Trunk以及三层交换
- Sublime在ubuntu下的安装
- System.IO 命名空间
- Nginx配置与应用详解
- [HNOI2012]archery
- JS中的event 对象详解
- 【apache2.2】apache2.2中的日志访问文件access.log
- 堆栈区别
- JS中event详解
- 集合框架的构成及分类
- 如何清除tomcat缓存
- 如何解决tomcat端口被占用的问题
- vmware server FileNotFound: A file was not found