lines-HDU5124(区间处理 +离散化)
Each test case begins with an integer N(1≤N≤105),indicating the number of lines.
Next N lines contains two integers Xi and Yi(1≤Xi≤Yi≤109),describing a line.
5
1 2
2 2
2 4
3 4
5 1000
5
1 1
2 2
3 3
4 4
5 5
1
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
#define N 1100000 struct node
{
int x,y;
}a[N];
int f[N],p[N]; int main()
{
int T,n,i;
scanf("%d",&T);
while(T--)
{
int k=;
memset(a,,sizeof(a));
memset(f,,sizeof(f));
memset(p,,sizeof(p));
scanf("%d",&n);
for(i=;i<n;i++)
{
scanf("%d %d",&a[i].x,&a[i].y);
p[k++]=a[i].x;
p[k++]=a[i].y;
}
sort(p,p+k);
int len=unique(p,p+k)-p;
int Max=;
for(i=;i<n;i++)
{
int u=lower_bound(p,p+len,a[i].x)-p;
int v=lower_bound(p,p+len,a[i].y)-p;
f[u]++;
f[v+]--;
Max=max(Max,v+);
}
int ans=,b=;
for(i=;i<=Max;i++)
{
ans+=f[i];
b=max(b,ans);
}
printf("%d\n",b);
}
return ;
}
lines-HDU5124(区间处理 +离散化)的更多相关文章
- POJ-2528 Mayor's posters (线段树区间更新+离散化)
题目分析:线段树区间更新+离散化 代码如下: # include<iostream> # include<cstdio> # include<queue> # in ...
- POJ 2528 Mayor's posters (线段树+区间覆盖+离散化)
题意: 一共有n张海报, 按次序贴在墙上, 后贴的海报可以覆盖先贴的海报, 问一共有多少种海报出现过. 题解: 因为长度最大可以达到1e7, 但是最多只有2e4的区间个数,并且最后只是统计能看见的不同 ...
- HDU5124:lines(线段树+离散化)或(离散化思想)
http://acm.hdu.edu.cn/showproblem.php?pid=5124 Problem Description John has several lines. The lines ...
- POJ 2528 Mayor's posters(线段树/区间更新 离散化)
题目链接: 传送门 Mayor's posters Time Limit: 1000MS Memory Limit: 65536K Description The citizens of By ...
- POJ 2528 Mayor's posters(线段树区间染色+离散化或倒序更新)
Mayor's posters Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 59239 Accepted: 17157 ...
- poj-----(2528)Mayor's posters(线段树区间更新及区间统计+离散化)
Mayor's posters Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 43507 Accepted: 12693 ...
- POJ2528:Mayor's posters(线段树区间更新+离散化)
Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral electio ...
- Educational Codeforces Round 10 D. Nested Segments 【树状数组区间更新 + 离散化 + stl】
任意门:http://codeforces.com/contest/652/problem/D D. Nested Segments time limit per test 2 seconds mem ...
- POJ-2528 Mayor's posters(线段树区间更新+离散化)
http://poj.org/problem?id=2528 https://www.luogu.org/problem/UVA10587 Description The citizens of By ...
- hiho一下21周 线段树的区间修改 离散化
离散化 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho在回国之后,重新过起了朝7晚5的学生生活,当然了,他们还是在一直学习着各种算法~ 这天小Hi和小Ho ...
随机推荐
- AJPFX关于Java Object类常用方法小总结
java.lang.Object java.lang包在使用的时候无需显示导入,编译时由编译器自动导入. Object类是类层次结构的根,Java中所有的类从根本上都继承自这个类. Object类 ...
- dotnet cors 跨域问题
研究了一整子的.net core框架,感觉挺好用的,可以用在实际项目中,前端avalon框架也在研究: 问题:跨域,相比原来的跨域解决方案,还是有不小的变化的,原来的.net api 只需要在WebA ...
- [BZOJ1192][HNOI2006]鬼谷子的钱袋 数学
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1192 大水题,把m分成二的幂次方和. #include<cstdio> #in ...
- Bing图片下载器(Python实现)
分享一个Python实现的Bing图片下载器.下载首页图片并保存到到当前目录.其中用到了正则库re以及Request库. 大致流程如下: 1.Request抓取首页数据 2.re正则匹配首页图片URL ...
- Jquery+ashx实现Ajax
一 Ajax的实现方式 1.使用一般的webform,在页面用jQuery ajax调用,再从取得的html数据中取得<body>内的内容,写入DOM 优点:不用改变现有的asp.net开 ...
- ASP.NET控件的ID,ClientID,UniqueId的区别
一般情况下三者相同(没有父控件) ID:获取或设置分配给服务器控件的编程标识符.分配给控件的编程标识符. (可写) 设置服务器控件上的此属性可提供对服务器控件的属性.事件和方法的编程访问.Web 开发 ...
- .net 操作xml --移除注释节点
/// <summary> /// xml字符串转xml文档 忽略注释信息 /// </summary> /// <param name="sXml" ...
- Divide and Conquer_1.最大连续子数组
给定一个数组,求它的一个子数组,使其求和最大. 这个问题的应用:给定一只股票很多天的价格,计算从哪天买进哪天卖出能获得最大利润. 给定 prices:100 113 98 87 65 ...
- Shorthand Argument Names $0 : 只用于指代Closer声明中的形参
Shorthand Argument Names Swift automatically provides shorthand argument names to inline closures, w ...
- windows sdk 设置窗体透明
#define WINVER 0x0501 #include <windows.h> /* Declare Windows procedure */ LRESULT CALLBACK Wi ...