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. BNUOJ 12756 Social Holidaying(二分匹配)

    题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=12756 Social Holidaying Time Limit: 3000ms Memo ...

  2. Once you eliminate all the other factors,the only thing remaining must be the truth.

    Once you eliminate all the other factors,the only thing remaining must be the truth. 一旦你排除了杂因,剩下的一定是 ...

  3. 【HASPDOG】Communication error

    靠,防火墙没关,关了防火墙生成文件成功

  4. 【Git】Git与GitHub 入门【转】

    转自:http://www.cnblogs.com/lcw/p/3394545.html GitHub GitHub是一个基于git的代码托管平台,付费用户可以建私人仓库,我们一般的免费用户只能使用公 ...

  5. linux下定时器介绍2--timer_create等函数集的使用示例

    程序1:采用新线程派驻的通知方式 程序2:通知方式为信号的处理方式 #include <stdio.h>#include <time.h>#include <stdlib ...

  6. LVS ARP广播产生的问题和处理方式【转】

    转自 LVS ARP广播产生的问题和处理方式-htckiller2010-ChinaUnix博客http://blog.chinaunix.net/uid-24960107-id-193084.htm ...

  7. 【转】WCF光芒下的Web Service

    WCF光芒下的Web Service 学习.NET的开发人员,在WCF的光芒照耀下,Web Service 似乎快要被人遗忘了.因为身边做技术的人一开口就是WCF多么的牛逼!废话不多,本人很久不写博客 ...

  8. python configparser配置文件解析器

    一.Configparser 此模块提供实现基本配置语言的ConfigParser类,该语言提供类似于Microsoft Windows INI文件中的结构.我们经常会在一些软件安装目录下看到.ini ...

  9. mac 删除垃圾篓中的文件

    1.打开终端输入: sudo rm -rf /Volumes/kaid/.Trashes/ 2.输入本机密码

  10. rsync + inotify 实时同步

    1. 前言 2 台 nginx 需要做集群, 静态文件和php文件都在nginx服务器本地. 有三种方案: (1)NFS (2)Rsync + inotify (3)共享存储服务器 第一种:当 nfs ...