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[ ...
随机推荐
- 适配器在JavaScript中的体现
适配器设计模式在JavaScript中非常有用,在处理跨浏览器兼容问题.整合多个第三方SDK的调用,都可以看到它的身影. 其实在日常开发中,很多时候会不经意间写出符合某种设计模式的代码,毕竟设计模式就 ...
- css3新增的属性
由于CSS5标准还未完全订下来,所以各种内核的浏览器都有自己的标准,为了不使属性混淆,所以各家在各自标准前加了一个前缀, 如:-moz- firefox火狐 -ms- IE ...
- sql_injection之基本get注入
1.代码篇 <?php error_reporting(0); include("../conn.php"); if(isset($_GET['id'])){ $id=$_G ...
- 【FCS NOI2018】福建省冬摸鱼笔记 day1
省冬的第一天. 带了本子,笔,一本<算法导论>就去了.惊讶于为什么同学不带本子记笔记. 他们说:“都学过了.”,果然这才是巨神吧. 第一天:数论,讲师:zzx 前几页的课件挺水,瞎记了点笔 ...
- 邮件伪造测试-Swaks
1. 前言 在kali中自带一个邮件伪造工具Swaks,工具项目主页为 http://jetmore.org/john/code/swaks 2.基本用法: swaks --to --from --e ...
- jenkins 入门教程(上)【转】
转自:https://www.cnblogs.com/yjmyzz/p/jenkins-tutorial-part-1.html jenkins是一个广泛用于持续构建的可视化web工具,持续构建说得更 ...
- Python缓存技术,装x新高度。
一段非常简单代码 普通调用方式 def console1(a, b): print("进入函数") return (a, b) print(console1(3, 'a')) pr ...
- sicily 1459. The Dragon of Loowater
Time Limit: 1sec Memory Limit:32MB Description Once upon a time, in the Kingdom of Loowa ...
- 读书笔记 effective c++ Item 19 像设计类型(type)一样设计类
1. 你需要重视类的设计 c++同其他面向对象编程语言一样,定义了一个新的类就相当于定义了一个新的类型(type),因此作为一个c++开发人员,大量时间会被花费在扩张你的类型系统上面.这意味着你不仅仅 ...
- 空洞卷积(dilated Convolution) 与感受野(Receptive Field)
一.空洞卷积 空洞卷积是是为了解决基于FCN思想的语义分割中,输出图像的size要求和输入图像的size一致而需要upsample,但由于FCN中使用pooling操作来增大感受野同时降低分辨率,导致 ...