POJ1151 Atlantis 水题 计算几何
http://poj.org/problem?id=1151
想学一下扫描线线段树,结果写了道水题。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
using namespace std;
const int maxn=;
int n;
double a1[maxn][];
int a[maxn][];
double b[maxn*],c[maxn*];
int tot=,tot1=;
int main(){
for(int T=;;T++){
scanf("%d",&n);
if(n==)break;
tot=,tot1=;
for(int i=;i<=n;i++){
scanf("%lf%lf%lf%lf",&a1[i][],&a1[i][],&a1[i][],&a1[i][]);
b[++tot]=a1[i][];b[++tot]=a1[i][];
c[++tot1]=a1[i][];c[++tot1]=a1[i][];
}
sort(b+,b++tot);sort(c+,c++tot1);
tot=unique(b+,b++tot)-b-;
tot1=unique(c+,c++tot1)-c-;
for(int i=;i<=n;i++){
a[i][]=lower_bound(b+,b++tot,a1[i][])-b;
a[i][]=lower_bound(c+,c++tot1,a1[i][])-c;
a[i][]=lower_bound(b+,b++tot,a1[i][])-b;
a[i][]=lower_bound(c+,c++tot1,a1[i][])-c;
}double ans=;
for(int i=;i<tot;i++){
for(int j=;j<tot1;j++){
int f=;
for(int z=;z<=n;z++){
if(i+<=a[z][]&&i>=a[z][]&&j+<=a[z][]&&j>=a[z][]){
f=;break;
}
}
if(f){
ans+=(b[i+]-b[i])*(c[j+]-c[j]);
}
}
}
printf("Test case #%d\n",T);
printf("Total explored area: %.2f\n\n",ans);
}
return ;
}
POJ1151 Atlantis 水题 计算几何的更多相关文章
- hdu 2393:Higher Math(计算几何,水题)
Higher Math Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hrbustoj 1306:再遇攻击(计算几何,判断点是否在多边形内,水题)
再遇攻击 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 253(37 users) Total Accepted: 56(2 ...
- hdu 1140:War on Weather(计算几何,水题)
War on Weather Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- [POJ1151]Atlantis
[POJ1151]Atlantis 试题描述 There are several ancient Greek texts that contain descriptions of the fabled ...
- POJ 水题(刷题)进阶
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
随机推荐
- yii验证系统学习记录,基于yiicms(二)
/** * Validates the specified object. * @param \yii\base\Model $model the data model being validated ...
- python 面试题3
注:本面试题来源于网络. 1.python下多线程的限制以及多进程中传递参数的方式 python多线程有个全局解释器锁(global interpreter lock),这个锁的意思是任一时间只能有一 ...
- SQL语句帮助大全
--删除约束 Status:字段名 alter table Table_1 drop constraint Status; --添加约束 --Status :字段名 t_Pay_Order:表名 默认 ...
- openjudge-NOI 2.5基本算法之搜索 专题题解目录
1.1700 八皇后问题 2.1756 八皇后 3.1789 算24
- 01 Getting Started 开始
Getting Started 开始 Install the Go tools Test your installation Uninstalling Go Getting help Downlo ...
- P2184 【贪婪大陆】
看到全是线段树或者树状数组写法,就来提供一发全网唯一cdq分治三维偏序解法吧 容易发现,这个题的查询就是对于每个区间l,r,查询有多少个修改区间li,ri与l,r有交集 转化为数学语言,就是查询满足l ...
- 如何修改SQL Server 2000的数据库逻辑与物理名称
在项目中使用SQL Server 2000创建了一个数据库,发现名称与另一个数据库太相似,于是决定更改名称,包括: 在企业管理器中看到的数据库名,也是实际应用程序中连接用的数据库名称: 在磁盘上看的物 ...
- 阿里云宝塔Linux服务器管理面版初始化地址不能登入(原创)
宝塔面板是一款可以让Linux服务器实现图形可视化操作的集成系统. 安装好以后,页面初始化登录地址http://{您的服务器IP}:888不能登入. 不能登入通常是我们没有权限访问,需要更改安全组赋予 ...
- java异常查看利器之使用 jvmti 的Callback_JVMTI_EVENT_EXCEPTION 事件查看异常
阅读本文前需要了解什么是jvmti,jvmti全称称之为 JVM Tool Interface,有关jvmti更详细的知识,本文不再详细列出.大家可以借助百度来了解有关它更为详尽的内容. 在开源文件大 ...
- 【LOJ】#2497. 「PA 2017」Banany
题解 一眼就是线段树维护点分树的dfs序嘛 代码debug一年(手动再见) 码力直线下降,坐等滚粗= = 很明显的我们需要一个点分树,然后求出以每个重心为根的树的dfs序,线段树维护一下每个点的价值- ...