【题目描述】

Remmarguts公主成功地解决了象棋问题。作为奖励,Uyuw计划举办一场音乐会,地点是以其伟大的设计师Ihsnayish命名的巨大广场。

这个位于自由三角洲联合王国(UDF,United Delta of Freedom)最繁华地带的广场是一个坐标范围[0,10000]*[0,10000]的正方形。有一些长椅已经固定在广场上许多年了,但是杂乱无章。见下图:

我们有三张长椅,并且观众面对的方向已经用箭头画出。这些椅子年代久远,并且沉重得无法移动。Remmarguts公主让广场现在的主人UW先生在广场上修建一个大的舞台。这个舞台应当尽可能大,但必须确保在任意长椅上任意位置的观众不必转身就能看到舞台(也就是说舞台必须在长椅所在直线的观众朝向那一侧)。

为了简化问题,舞台的高度可以任意高来确保只要你面向舞台所在的那一侧,你就能看到舞台上的歌唱家/画家——Uyuw,即使你的面前有数千张长椅。

作为一名脑残粉,你能告诉他们舞台的最大面积吗?

【输入格式】

输入包含不超过10组数据。

每组数据格式如下:

第一行有一个整数N(N<=20000),代表长椅的数量。

接下来有N行,每行有4个整数x1,y1,x2,y2,代表一张长椅。这张长椅是以(x1,y1)和(x2,y2)为端点的线段,并且面向其左侧。一个点(x,y)在线段左侧是指(x-x1)*(y-y2)-(x-x2)*(y-y1)>=0.

【输出格式】

对每组数据输出一个一个实数,即舞台的最大面积。精确到1位小数。你的答案被认为是正确的当且仅当它与标准答案之差小于0.2。

【样例输入】

3

10000 10000 0 5000

10000 5000 5000 10000

0 5000 5000 0

【样例输出】

54166666.7

【提示】

样例如下:

建议你采用Pascal中的Extended类型或者C/C++中的long double类型来避免精度误差。不过标程仅仅用了double。

半平面交模板(太坑了)

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef double ld;
struct point
{
ld x,y;
point(){}
point(ld _x,ld _y) {x=_x,y=_y;}
}p[];
struct Line
{
point a,b;
ld angle;
Line(){}
Line(point _a,point _b) {a=_a,b=_b;}
}line[],sta[];
ld eps=1e-,ans;
int n,cnt;
point operator -(point a,point b)
{
return point(a.x-b.x,a.y-b.y);
}
int dcmp(ld x)
{
if (x>eps) return ;
if (x<-eps) return -;
return ;
}
ld cross(point a,point b)
{
return a.x*b.y-a.y*b.x;
}
ld getangle(Line l)
{
return atan2(l.b.y-l.a.y,l.b.x-l.a.x);
}
point inter(Line u,Line v)
{
double k1=(cross((u.b-v.a),(v.b-v.a)));
double k2=(cross((v.b-v.a),(u.a-v.a)));
double t=k1/(k1+k2);
return point(u.b.x+(u.a.x-u.b.x)*t,u.b.y+(u.a.y-u.b.y)*t);
}
bool cmp(Line u,Line v)
{
int t=dcmp(u.angle-v.angle);
if (t) return t<;
return dcmp(cross(u.a-v.b,v.a-v.b))>;
}
bool judge(Line a,Line b,Line c)
{
point p=inter(b,c);
return dcmp(cross(a.a-p,a.b-p))<;
}
void HPT()
{int i,head,tail;
sort(line+,line+n+,cmp);
int tmp=;
for (i=;i<=n;i++)
if (dcmp(line[i].angle-line[i-].angle)!=)
line[++tmp]=line[i];
n=tmp;
head=,tail=;
sta[]=line[];sta[]=line[];
for (i=;i<=n;i++)
{
while (tail->=head&&judge(line[i],sta[tail],sta[tail-])) tail--;
while (head+<=tail&&judge(line[i],sta[head+],sta[head])) head++;
tail++;
sta[tail]=line[i];
}
while (tail->=head&&judge(sta[head],sta[tail],sta[tail-])) tail--;
while (head+<=tail&&judge(sta[tail],sta[head+],sta[head])) head++;
cnt=;
if (tail-head<=) return;
for (i=head;i<tail;i++)
{
p[++cnt]=inter(sta[i],sta[i+]);
}
if (tail>head+)
p[++cnt]=inter(sta[head],sta[tail]);
}
int main()
{
int i;
while (cin>>n)
{
n+=;
line[]=Line(point(,),point(,));
line[]=Line(point(,),point(,));
line[]=Line(point(,),point(,));
line[]=Line(point(,),point(,));
line[].angle=getangle(line[]);
line[].angle=getangle(line[]);
line[].angle=getangle(line[]);
line[].angle=getangle(line[]);
for (i=;i<=n;i++)
{
scanf("%lf%lf%lf%lf",&line[i].a.x,&line[i].a.y,&line[i].b.x,&line[i].b.y);
line[i].angle=getangle(line[i]);
}
HPT();
ans=;
for (i=;i<cnt;i++)
{
ans+=cross(p[i]-p[],p[i+]-p[])/2.0;
}
ans=fabs(ans);
printf("%.1lf\n",ans);
}
return ;
}

poj 2451 Uyuw's Concert的更多相关文章

  1. poj 2451 Uyuw's Concert (半平面交)

    2451 -- Uyuw's Concert 继续半平面交,这还是简单的半平面交求面积,不过输入用cin超时了一次. 代码如下: #include <cstdio> #include &l ...

  2. POJ 2451 Uyuw's Concert (半平面交)

    题目链接:POJ 2451 Problem Description Prince Remmarguts solved the CHESS puzzle successfully. As an awar ...

  3. poj 2451 Uyuw's Concert(半平面交)

    Uyuw's Concert Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 8580   Accepted: 3227 De ...

  4. POJ 2451 Uyuw's Concert(半平面交nlgn)

    //#pragma comment(linker, "/STACK:16777216") //for c++ Compiler #include <stdio.h> # ...

  5. bzoj 2451 Uyuw's Concert

    裸的半平面交.感觉这些东西,纯属在考代码能力啊.. #include<cstdio> #include<algorithm> #include<cmath> #de ...

  6. 计算几何模板 (bzoj 1336,poj 2451 ,poj3968)

    poj 3968 (bzoj 2642) 二分+半平面交,每次不用排序,这是几个算几版综合. #include<iostream> #include<cstdio> #incl ...

  7. POJ2451 Uyuw's Concert(半平面交)

    题意就是给你很多个半平面,求半平面交出来的凸包的面积. 半平面交有O(n^2)的算法,就是每次用一个新的半平面去切已有的凸包,更新,这个写起来感觉也不是特别好写. 另外一个O(nlogn)的算法是将半 ...

  8. Uyuw's Concert POJ2451

    裸半平面交,以前没写过,先写一遍再说 我越来越不注意细节了,最后才发现空间稍微开小了(没有开那个零头,他又要多4条边,就WA了) const maxn=; eps=1e-7; type point=r ...

  9. [poj2451]Uyuw's Concert

    半平面交滴裸题,但是要求nlogn,练练手 #include<iostream> #include<cstdio> #include<cmath> #include ...

随机推荐

  1. SQL函数返回表的示例-Z

    create function [dbo].[GetOperateCustGroup] ( ), ) ) returns @TempTable table (MaxPrice float,MinPri ...

  2. transient 与 volatile 笔记

    1. transient 词义:瞬间的,短暂的 首先说说"序列化",把一个对象的表示转化为字节流的过程称为串行化(也称为序列化,serialization),从字节流中把对象重建出 ...

  3. HTTP协议以及HTTP2.0/1.1/1.0区别

    HTTP协议以及HTTP2.0/1.1/1.0区别 一.简介 摘自百度百科: 超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议.所 ...

  4. Python习题(第一课)

    想了想其他的太简单了,还是不放了,剩三题吧. 一.完美立方 编写一个程序,对任给的正整数N (N≤100),寻找所有的四元组(a, b, c, d),使得a^3= b^3 + c^3 + d^3,其中 ...

  5. zookeeper安装及环境变量设置

    下载 首先去官网下载(自行选择版本):http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.11/然后执行tar -zxvf解压 对于后台安装 ...

  6. CentOS 7 安装Graphite

    Graphite简介 Graphite是一个Python编写的企业级开源监控工具,采用django框架,用来收集服务器所有的即时状态,用户请求信息,Memcached命中率,RabbitMQ消息服务器 ...

  7. 职场选择之大公司 VS 小公司

    其实这是个非常难回答的问题,很多职场新人都会有类似的顾虑和疑问. 这个问题就好比业界比较容易引起争议的编程语言哪个是最好的一样.大公司还是小公司里面发展,只有身处其中才能体会,如人饮水,冷暖自知. 笔 ...

  8. Spring知识点回顾(08)spring aware

    Spring知识点回顾(08)spring aware BeanNameAware 获得容器中的bean名称 BeanFactoryAware 获得当前的bean factory Applicatio ...

  9. 新概念英语(1-61)A bad cold

    新概念英语(1-61)A bad cold What is good news for Jimmy? A:Where's Jimmy? B:He's in bed. A:What's the matt ...

  10. ssh整合之七注解结合xml形式

    1.我们之前的纯xml的方式,我们的配置文件很多,我们可以使用注解结合xml的方式进行开发,这样的话,我们的配置文件,会少很多,同时,我们可以直接在类中看到配置,这样,我们就可以快速地搭建一个ssh整 ...