旋转卡壳

算法请自行百度,本文专门用来贴代码,想学算法的请直接无视

tyvj的某题

Code:

type
        int=longint;
        real=extended;
        point=record
                x,y:real;
        end;
        line=record
                a,b,c:real;
        end;
const e=1e-10;maxn = 100010;

operator *(a,b:point)c:real;
begin c:=a.x*b.y-a.y*b.x;end;

operator -(a,b:point)c:point;
begin c.x:=a.x-b.x;c.y:=a.y-b.y;end;

function d(a,b:point):real;
begin d:=sqr(a.x-b.x)+sqr(a.y-b.y);end;

var
        i,j,m,n:int;k,x:point;
        max,ans,t:real;
        a:array[1..maxn]of point;
        p:array[0..maxn]of int;

procedure sort(l,r:int);
var i,j:int;m:real;
begin
        m:=a[(l+r)>>1].x;
        i:=l;j:=r;
        repeat
                while a[i].x<m do inc(i);
                while a[j].x>m do dec(j);
                if i<=j then begin
                        k:=a[i];a[i]:=a[j];a[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 hull();
begin
        m:=1;p[0]:=1;p[1]:=2;
        for i:=3 to n do begin
                while(m<>0)and((a[i]-a[p[m]])*(a[p[m]]-a[p[m-1]])>0)do dec(m);
                inc(m);p[m]:=i;
        end;
        inc(m);p[m]:=n-1;
        for i:=n-2 downto 1 do begin
                while(m<>1)and((a[i]-a[p[m]])*(a[p[m]]-a[p[m-1]])>0)do dec(m);
                inc(m);p[m]:=i;
        end;
end;

function deal(x,y,z:int;var max:real):boolean;
begin
        t:=(a[p[x]]-a[p[z]])*(a[p[y]]-a[p[z]]);
        if t<0 then t:=-t;
        if max>t then exit(false);
        max:=t;deal:=true;
end;

procedure main;
begin
        j:=1;
        for i:=0 to m-1 do begin
                max:=(a[p[i]]-a[p[j]])*(a[p[i+1]]-a[p[j]]);
                if max<0 then max:=-max;
                while(deal(i,i+1,(j+1)mod(m+1),max))do j:=(j+1)mod(m+1);
                t:=d(a[p[i]],a[p[j]]);
                if t>ans then ans:=t;
                t:=d(a[p[i]],a[p[i+1]]);
                if t>ans then ans:=t;
        end;
end;

begin
        assign(input,'data.txt');reset(input);
        assign(output,'ans.txt');rewrite(output);
        read(n);
        for i:=1 to n do begin
                read(a[i].x,a[i].y);
                a[i].x:=a[i].x+(random*e)/100;
                a[i].y:=a[i].y+(random*e)/100;
        end;
        sort(1,n);
        hull;
        main;
        write(ans:0:0);
        close(input);close(output);
end.

半平面交+旋转卡壳,花了我一下午+一节晚自习TAT

Code:

program circles;
uses math;
type
        int=longint;
        real=extended;
        point=record
                x,y:real;
        end;
        line=record
                a,b,c:real;
        end;
const
        maxn=70000;
        e=1e-7;

operator +(a,b:point)c:point;
begin c.x:=a.x+b.x;c.y:=a.y+b.y;end;

operator -(a,b:point)c:point;
begin c.x:=a.x-b.x;c.y:=a.y-b.y;end;

operator *(a,b:point)c:real;
begin c:=a.x*b.y-a.y*b.x;end;

operator **(a,b:point)c:real;
begin c:=a.x*b.x+a.y*b.y;end;

operator /(a,b:point)c:real;
begin c:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));end;

operator *(a,b:line)c:point;
var s,x,y:real;
begin
        s:=b.b*a.a-a.b*b.a;
        y:=b.c*a.a-a.c*b.a;
        x:=b.c*a.b-a.c*b.b;
        c.x:=-x/s;c.y:=y/s;
end;

operator =(a:point;b:line)c:boolean;
begin c:=b.a*a.x+b.b*a.y-b.c<-e;end;

var
        i,j,m,n,h:int;
        a,c:array[0..maxn]of point;
        l:array[0..maxn]of line;
        p:array[0..maxn]of int;
        lb,rb,mid,z,ans:real;
        t,k,source:point;

procedure up(var x:int);
begin x:=(x+1)mod(m+1);end;

function plane:boolean;
begin
        m:=2;h:=2;
        p[1]:=1;p[2]:=2;
        c[2]:=l[1]*l[2];
        for i:=3 to n do begin
                while(h<=m)and(c[m]=l[i])do dec(m);
                while(h<=m)and(c[h]=l[i])do inc(h);
                if l[i].b*l[p[m]].a-l[p[m]].b*l[i].a=0 then exit(false);
                inc(m);p[m]:=i;
                c[m]:=l[i]*l[p[m-1]];
        end;
        while(h<m)and(c[m]=l[p[h-1]])do dec(m);
        while(h<m)and(c[h]=l[p[m]])do inc(h);
        if m-h<1 then exit(false);
        c[m+1]:=l[p[m]]*l[p[h-1]];
        exit(true);
end;

function maxi(var x:real;y:real):boolean;
begin
        maxi:=x<y;
        if x<y then x:=y;
end;

function ok(x:real):boolean;
begin
        for i:=1 to n do begin
                t.x:=l[i].a;t.y:=l[i].b;
                l[i].c:=t**a[i]+x*(t/source);
        end;
        if not plane then exit(false);
        for i:=0 to m-h+1 do c[i]:=c[i+h];
        m:=m-h+1;c[m+1]:=c[0];
        j:=1;ans:=-1;
        for i:=0 to m-1 do begin
                z:=(c[i]-c[j])*(c[i+1]-c[j]);up(j);
                while(maxi(z,(c[i]-c[j])*(c[i+1]-c[j])))do up(j);
                dec(j);if j<0 then j:=m;
                z:=c[i]/c[j];
                if z>ans then ans:=z;
                z:=c[i+1]/c[i];
                if z>ans then ans:=z;
        end;
        ok:=ans/2>x;
end;

begin
        assign(input,'2circles.in');reset(input);
        assign(output,'2circles.out');rewrite(output);
        randomize;
        read(n);
        fillchar(source,sizeof(source),0);
        for i:=1 to n do read(a[i].x,a[i].y);
        a[n+1]:=a[1];
        for i:=1 to n do begin
                t:=a[i+1]-a[i];
                l[i].a:=-t.y;l[i].b:=t.x;
        end;
        lb:=0;rb:=1e8;
        while rb-lb>0.0003 do begin
                mid:=(lb+rb)/2;
                if ok(mid)then lb:=mid
                        else rb:=mid;
        end;
        write(lb:0:3);
        close(input);close(output);
end.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园整体解决方案是响应国家教育信息化政策,结合教育改革和技术创新的产物。该方案以物联网、大数据、人工智能和移动互联技术为基础,旨在打造一个安全、高效、互动且环保的教育环境。方案强调从数字化校园向智慧校园的转变,通过自动数据采集、智能分析和按需服务,实现校园业务的智能化管理。 方案的总体设计原则包括应用至上、分层设计和互联互通,确保系统能够满足不同用户角色的需求,并实现数据和资源的整合与共享。框架设计涵盖了校园安全、管理、教学、环境等多个方面,构建了一个全面的校园应用生态系统。这包括智慧安全系统、校园身份识别、智能排课及选课系统、智慧学习系统、精品录播教室方案等,以支持个性化学习和教学评估。 建设内容突出了智慧安全和智慧管理的重要性。智慧安全管理通过分布式录播系统和紧急预案一键启动功能,增强校园安全预警和事件响应能力。智慧管理系统则利用物联网技术,实现人员和设备的智能管理,提高校园运营效率。 智慧教学部分,方案提供了智慧学习系统和精品录播教室方案,支持专业级学习硬件和智能化网络管理,促进个性化学习和教学资源的高效利用。同时,教学质量评估中心和资源应用平台的建设,旨在提升教学评估的科学性和教育资源的共享性。 智慧环境建设则侧重于基于物联网的设备管理,通过智慧教室管理系统实现教室环境的智能控制和能效管理,打造绿色、节能的校园环境。电子班牌和校园信息发布系统的建设,将作为智慧校园的核心和入口,提供教务、一卡通、图书馆等系统的集成信息。 总体而言,智慧校园整体解决方案通过集成先进技术,不仅提升了校园的信息化水平,而且优化了教学和管理流程,为学生、教师和家长提供了更加便捷、个性化的教育体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值