题目链接:http://poj.org/problem?id=1151

关于离散化,这篇博客讲的很好:http://www.cppblog.com/MiYu/archive/2010/10/15/129999.aspx

我线段树还是不会写这个。。

借个图:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAArAAAAItCAIAAABO3t58AAAgAElEQVR4nO2dPY7bSreuOaNOjDMGz+CLFHkK/sILdCocGDs0DuDkZgc4wVbim9rBDk/YwYYTT2DPoW4gieLPIlViiatqvf08EIx2t0qPFlWselWkxC4BAADAu6er/QQAAACgPgQCAAAAUAkEh5f0Nvjv8SWdlu+8/lcAAIB3SJdS+tSl7nr7Pvjbp4xf/vpya3u+ffllaMyHSiml79Yvl1t9+TByfer/cEovx1vD9Sn/7Zi6w/KfAQAA3h9d+pU+fbn859eX1H1I5wn9y4frdPs9dZ8udzB/eeNX+mDN7outfqUPZkrIeQJXTodbPugzwSQQvB2nqWV6Ix8AAMD7ZnzIYDCjf+rn6Xu/7Pn+KX34kuYstfrUpS+/Bn/NaDUPBD2HLh2vhw2OL+nl5fbfIcf+92/J+jsAAMB7ZBQIbisEw5m7/9n85a2xvTyw1Kqf2u1AsNzKOF5wXic4pJTS8ZjSedY/pq5Lh/GRg2FoSG/ppbNDw/ABAQAA3gOjQPCpn2Wtt/L2L68sLQ+YrYZ3vh8IZq6ULicfXH55Sl2Xjm/p+HI5anA5ZHC6ZYLjy+LxAjMTEAgAAOBdcQsEn7rBjP7oCsHS8sBCq8m5gcapiOurESmlfo3hdHuQfj3gdg7BW3oZzutv6eX6eYT+gwl86AAAAOASCD5102PzD51DsLg8sNpq+tdHWvXP+XS4rA0cDqnrLlP74hx/ur3vn3xSEQAA4D1z+djh/Ey9Bz5lsHCC4foHFno+jYPFWqtB8+EHIlJ/quB1vl8KBMeX2yrCLRCcUjcLBxwyAACAd0V3Phhvfrg/53sIUkpfPhjLA8Opfemh+j+ZgcBodf2Y4vyhjuPPFJiB4NCNvqtgFAhmcz+BAAAA3hUi31S4HghOg6MJw/vMTz4AAAB4n4gEAg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O74fHvg/P53H6Ekf4AY9AAAgN2pEggeXZl4yAV60AMAAHah8KTCh1ptbrv5HEbQgx4AALAXntcXmLTqxiw9DscLoIdOAADgx7ap91kTNhM/rEDnAABwgjQALUP/AAAAAAIBAAAAEAgAAHZl2/cLbT7Rb9sXHnM0ARKBAABgPzbMtYUfO9z83QNkAqAHAADsiFsgON9587xOIAB6AADAjrjN0JsDAYcM4AydAABgR9xOBSjRlTQEGegBAAA7su0t+zaR59mIoAc9AABgRwovULSrjpMKYQg9AABgLzZclSDzGgTrzfNb8bFD6KETAAD44bmezzQPD0F3AQBwgjQALUOPAQAAAAIBAAAAEAgAAHaFaxlAFOgEAAB7wbUMIBD0AACAHeFaBhAFegAAwI5wLQOIAp0AAGBHuJYBRIEeAACwI1zLAKJADwAA2BGuZQBRoAcAAOwF1zKAQNAJAAD84NuLoVnoLgAATpAGoGXoMQAAAEAgAAAAAAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAAJAIBAAAApJS6/wUAAIB3D4EAAAAA/vf/A7ksRKAemQ7lAAAAAElFTkSuQmCC" alt="" />

///离散化
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <cmath>
using namespace std;
const int N = ;
const double eps = 1e-;
struct Rec{
double x1,y1;
double x2,y2;
}rec[N];
double x[N],y[N];
int vis[N][N];
int n,k;
int cmp(double a,double b){
if(a<b) return ;
return ;
}
void input(){
k = ;
for(int i=;i<n;i++){
scanf("%lf%lf%lf%lf",&rec[i].x1,&rec[i].y1,&rec[i].x2,&rec[i].y2);
x[k] = rec[i].x1,y[k++] = rec[i].y1;
x[k] = rec[i].x2,y[k++] = rec[i].y2;
}
sort(x,x+k,cmp);
sort(y,y+k,cmp);
}
int binary1(double value){
int mid,l=,r=k-;
while(l<r){
mid = (l+r)>>;
if(fabs(x[mid]-value)<eps) return mid;
if(x[mid]<value) l = mid+;
else r = mid-;
}
return l;
}
int binary2(double value){
int mid,l=,r=k-;
while(l<r){
mid = (l+r)>>;
if(fabs(y[mid]-value)<eps) return mid;
if(y[mid]<value) l = mid+;
else r = mid-;
}
return l;
}
double solve(){
int t1,t2,t3,t4;
for(int i=;i<n;i++){
t1 = binary1(rec[i].x1);
t2 = binary1(rec[i].x2);
t3 = binary2(rec[i].y1);
t4 = binary2(rec[i].y2);
for(int j=t1;j<t2;j++){
for(int l = t3;l<t4;l++){
vis[j][l]=;
}
}
}
double area = ;
for(int i=;i<k;i++){
for(int j=;j<k;j++){
area+=vis[i][j]*(x[i+]-x[i])*(y[j+]-y[j]);
}
}
return area;
}
int main()
{
int cnt=;
while(scanf("%d",&n)!=EOF&&n){
memset(vis,,sizeof(vis));
input();
printf("Test case #%d\nTotal explored area: %.2lf\n\n",cnt++,solve());
}
return ;
}

poj 1151(离散化+矩形面积并)的更多相关文章

  1. POJ 1151 Atlantis 矩形面积求交/线段树扫描线

    Atlantis 题目连接 http://poj.org/problem?id=1151 Description here are several ancient Greek texts that c ...

  2. POJ-1151-Atlantis(线段树+扫描线+离散化)[矩形面积并]

    题意:求矩形面积并 分析:使用线段树+扫描线...因为坐标是浮点数的,因此还需要离散化! 把矩形分成两条边,上边和下边,对横轴建树,然后从下到上扫描上去,用col表示该区间有多少个下边,sum代表该区 ...

  3. poj 2559 最大矩形面积(单调栈)

    题目:输入一个整数n,代表有n个  1(宽度) * h[i](高度)的矩形.接下来n个数依次给定一个矩形高度的高度h[i](i<=n). 求:在给定的依次排列的这堆矩形构成的图形里用一个矩形圈出 ...

  4. hdu 4419 线段树 扫描线 离散化 矩形面积

    //离散化 + 扫描线 + 线段树 //这个线段树跟平常不太一样的地方在于记录了区间两个信息,len[i]表示颜色为i的被覆盖的长度为len[i], num[i]表示颜色i 『完全』覆盖了该区间几层. ...

  5. HDU 1255 覆盖的面积 (扫描线 线段树 离散化 矩形面积并)

    题目链接 题意:中文题意. 分析:纯手敲,与上一道题目很相似,但是刚开始我以为只是把cnt>=0改成cnt>=2就行了,. 但是后来发现当当前加入的线段的范围之前 还有线段的时候就不行了, ...

  6. Poj 2559 最大矩形面积 v单调栈 分类: Brush Mode 2014-11-13 20:48 81人阅读 评论(0) 收藏

    #include<iostream> #include<stack> #include<stdio.h> using namespace std; struct n ...

  7. POJ 1151 Atlantis(线段树-扫描线,矩形面积并)

    题目链接:http://poj.org/problem?id=1151 题目大意:坐标轴上给你n个矩形, 问这n个矩形覆盖的面积 题目思路:矩形面积并. 代码如下: #include<stdio ...

  8. POJ 1151 / HDU 1542 Atlantis 线段树求矩形面积并

    题意:给出矩形两对角点坐标,求矩形面积并. 解法:线段树+离散化. 每加入一个矩形,将两个y值加入yy数组以待离散化,将左边界cover值置为1,右边界置为2,离散后建立的线段树其实是以y值建的树,线 ...

  9. POJ 1151 Atlantis 线段树求矩形面积并 方法详解

    第一次做线段树扫描法的题,网搜各种讲解,发现大多数都讲得太过简洁,不是太容易理解.所以自己打算写一个详细的.看完必会o(∩_∩)o 顾名思义,扫描法就是用一根想象中的线扫过所有矩形,在写代码的过程中, ...

随机推荐

  1. P2341 [HAOI2006]受欢迎的牛(tarjan+缩点)

    P2341 [HAOI2006]受欢迎的牛 题目描述 每头奶牛都梦想成为牛棚里的明星.被所有奶牛喜欢的奶牛就是一头明星奶牛.所有奶 牛都是自恋狂,每头奶牛总是喜欢自己的.奶牛之间的“喜欢”是可以传递的 ...

  2. TCP重组问题

    今天问题: vqmon 测试一pcap抓包文件18.pcap.发现实际输出的视频分片信息和抓包不符合. ===>pts : 00:00:33 Too much data in TCP recei ...

  3. angular 模块化之directive

    通过使用directive使页面模块化.需要哪部分直接调用即可.原本这些操作需要后端配合,现在前端即可.将原本的html代码拆为不同的模块,然后通过directive衔接加载到主页面中.首先页面通过d ...

  4. Unicode字符图标

    http://unicode-table.com/cn/#control-character

  5. nginx配置及HTTPS配置示例

    一.nginx简单配置示例 user www www; worker_processes ; #error_log logs/error.log; #error_log logs/error.log ...

  6. 孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容

     孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.打开文件后,要务必记得关闭,所以一般的写法应当 ...

  7. hnust 分蛋糕

    问题 B: 分蛋糕 时间限制: 1 Sec  内存限制: 128 MB提交: 2430  解决: 966[提交][状态][讨论版] 题目描述 今天是DK生日,由于DK的朋友很多,所以DK在蛋糕店定制了 ...

  8. vue实现数据的增删改查

    在管理员的一些后台页面里,个人中心里的数据列表里,都会有对这些数据进行增删改查的操作.比如在管理员后台的用户列表里,我们可以录入新用户的信息,也可以对既有的用户信息进行修改.在vue中,我们更应该专注 ...

  9. JSP/Servlet Web 学习笔记 DayThree

    JSP内置对象 使用JSP语法可以存取这些内置对象来执行JSP网页的Servlet环境相互作用.内置对象其实是由特定的Java类所产生的.每一种内置对象都映射到一个特定的Java类或者端口,在服务器运 ...

  10. jquery serialize() 方法

    ajax异步提交的时候,会使用该方法. 方法:jQuery ajax - serialize() 方法