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 水题 计算几何的更多相关文章

  1. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. hrbustoj 1306:再遇攻击(计算几何,判断点是否在多边形内,水题)

    再遇攻击 Time Limit: 1000 MS    Memory Limit: 65536 K Total Submit: 253(37 users)   Total Accepted: 56(2 ...

  3. hdu 1140:War on Weather(计算几何,水题)

    War on Weather Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  4. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  5. [POJ1151]Atlantis

    [POJ1151]Atlantis 试题描述 There are several ancient Greek texts that contain descriptions of the fabled ...

  6. POJ 水题(刷题)进阶

    转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...

  7. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  8. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  9. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

随机推荐

  1. UNIX环境高级编程 第7章 进程环境

    本章涉及C/C++程序中main函数是如何被调用的.命令行参数如何传递给main函数.程序的内存空间布局.程序如何使用环境变量.程序如何终止退出. main函数 C程序或C++程序总是从main函数开 ...

  2. java创建并配置多module的maven项目

    1 使用idea创建(推荐) 这篇博客写的特别好,很详细: https://blog.csdn.net/sinat_30160727/article/details/78109769 2 使用ecli ...

  3. linux arm的存储分布那些事之一【转】

    转自:http://blog.csdn.net/xiaojsj111/article/details/11724081 linux arm的存储分布那些事之一 linux arm 内存分布总览 上图是 ...

  4. mysql优化【转】

    最近听讲了博森瑞老师的mysql优化公开课,这个是我整理的笔记. 现在说一下mysql的内存和I/O方面的两个特点. 一. mysql内存特点: 1.  也有全局内存和每个session的内存(每个s ...

  5. linux服务器登录时慢出现卡顿

    使用SSH远程登录Linux在输入用户名之后在过了好几秒之后才会出现输入密码.严重影响工作效率.登录很慢,登录上去后速度正常,这种情况的主要原因为: DNS反向解析的问题 SSH在登录的时候一般我们输 ...

  6. plupload 上传组件的使用

    在这之前在感谢园子好多大牛的文章,在这里就不列出来了. 进入正题. svn检索https://github.com/moxiecode/plupload 获取到代码,这篇文章使用的是v2.1.8 主要 ...

  7. JUnit基本介绍

    一.什么是单元测试 单元测试(Unit  Testing)是指在计算机编程中,针对程序模块来进行正确性检验的测试工作.单元测试的特点如下: ※ 程序单元是应用最小的可测试部件,通常采用基于类或者类的方 ...

  8. Spark RDD 窄依赖研究

    1.. 简介 spark从RDD依赖上来说分为窄依赖和宽依赖. 其中可以这样区分是哪种依赖:当父RDD的一个partition被子RDD的多个partitions引用到的时候则说明是宽依赖,否则为窄依 ...

  9. 22 Gobs of data 设计和使用采集数据的包

    Gobs of data 24 March 2011 Introduction To transmit a data structure across a network or to store it ...

  10. ROSCon 2017通知 Announcing ROSCon 2017: September 21st and 22nd in Vancouver

    ROSCon 2017通知:9月21日和22日在温哥华 我们很高兴地宣布,2017年ROSCon将在举行9月21-22日,2017年温哥华会议中心在加拿大温哥华.2017年IROS将在同一地点9月24 ...