【题目描述】

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. Java读取文件存储到mysql

    写了一批Lua脚本,要放到数据库里面,调用的时候进行计算,由于有太多lua脚本,就写了个程序来录入. 下面主要分三个部分: public static String readToString(Stri ...

  2. Beta冲刺NO.7

    Beta冲刺 第七天 昨天的困难 昨天的困难在一些多表查询上,不熟悉hibernate的套路,走了很多弯路. 第一次使用图表插件,在图表的显示问题上花了一定的时间. 对于页面绑定和后台数据自动填充的理 ...

  3. js计时功能

    //个位秒加 function time4jia() { //分钟60为上限 所有加停止 if (sz(a('time1').innerHTML) == 6) { return; } var m4 = ...

  4. (转)如何在Eclipse中查看JDK类库的源代码

    在Eclipse中查看JDK类库的源代码!!! 设置: 1.点 “window”-> "Preferences" -> "Java" -> & ...

  5. LeetCode & Q14-Longest Common Prefix-Easy

    String Description: Write a function to find the longest common prefix string amongst an array of st ...

  6. 关于 Form 表单的 enctype 属性

    enctype 属性一共有3个值 application/x-www-form-urlencoded 在发送前编码所有字符(默认) multipart/form-data 上传二进制数据, 所以在使用 ...

  7. Python内置函数(33)——any

    英文文档: any(iterable) Return True if any element of the iterable is true. If the iterable is empty, re ...

  8. restful架构风格设计准则(三)资源识别和资源设计

    读书笔记,原文链接:http://www.cnblogs.com/loveis715/p/4669091.html,感谢作者! restful风格的设计中,首先要识别系统中的资源,然后用HTTP规范表 ...

  9. hadoop2.7.3+spark2.1.0+scala2.12.1环境搭建(2)安装hadoop

    一.依赖安装 安装JDK 二.文件准备 hadoop-2.7.3.tar.gz 2.2 下载地址 http://hadoop.apache.org/releases.html 三.工具准备 3.1 X ...

  10. .NET CORE 框架ABP的代码生成器(ABP Code Power Tools )使用说明文档

    前言 各位好,又是一个多月没更新文章了. 原因嘛,大家都懂的,太忙了~ 临近年末,公司的项目.年会的做技术支持,同事朋友聚餐也比较频繁. 当然视频教程也没有继续更新.我的锅~ 但是这个月好歹抽空做了一 ...