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[ ...
随机推荐
- Linux操作系统介绍
1Linux操作系统介绍 1.1linux系统的应用 服务器系统:Web应用服务器.数据库服务器.接口服务器.DNS.FTP等等: 嵌入式系统:路由器.防火墙.手机.PDA.IP 分享器.交换器.家电 ...
- Nginx常见错误与问题之解决方法技术指南
Nginx常见错误与问题之解决方法技术指南. 安装环境: 系统环境:redhat enterprise 6.5 64bit 1.Nginx 常见启动错误 有的时候初次安装nginx的时候会报这样的 ...
- vue+vuex+axios+echarts画一个动态更新的中国地图
一. 生成项目及安装插件 # 安装vue-cli npm install vue-cli -g # 初始化项目 vue init webpack china-map # 切到目录下 cd china- ...
- HDU 3360 National Treasures(最小点覆盖)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3360 题目大意: 在一个n*m的格子中,每个格子有一个数值,-1表示空,其余表示财宝.每个财宝的数值转 ...
- [经典算法题]寻找数组中第K大的数的方法总结
[经典算法题]寻找数组中第K大的数的方法总结 责任编辑:admin 日期:2012-11-26 字体:[大 中 小] 打印复制链接我要评论 今天看算法分析是,看到一个这样的问题,就是在一堆数据 ...
- MySQL学习笔记:like和regexp的区别
一.like关键字 like有两个模式:_和% _:表示单个字符,用来查询定长的数据 select name from table where name like '陈__'; %:表示0个或多个任意 ...
- CI框架整合UEditor编辑器上传功能
最近项目中要使用到富文本编辑器,选用了功能强大的UEditor,接下来就来讲讲UEditor编辑器的上传功能整合. 本文UEditor版本:ueditor1_4_3_utf8_php版本 第一步:部署 ...
- 配置toad远程连接oracle
在oracle服务器上: C:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN目录 文件:listener.ora(10.144.118 ...
- .NetCore读取配置Json文件到类中并在程序使用
ConfigurationBuilder 这个类提供了配置绑定,在dnc中 Program中WebHost提供了默认的绑定(appsettings文件) 如果我们需要加载我们自己的json配置文件怎么 ...
- Rookey.Frame之实体类
上周跟大家分享了Rookey.Frame框架的初始化功能,今天继续给大家介绍实体类的设计. 先看下下面菜单实体示例代码: using Rookey.Frame.EntityBase; using Ro ...