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 ...
随机推荐
- Scala基础篇-01变量,数据类型
一.Scala变量 共有3种变量修饰符: val: 可变 var: 不可变 lazy val: 第一次应用时才计算 二.Scala的数据类型 1)类型不匹配:高精度数值赋给低精度数据类型. 2)Uni ...
- GIS在石油行业中的应用
在石油工业中,发现新的石油资源,取得竞争优势,是成功的关键之一.GIS系统能帮助评估潜在的石油资源,及时.准确.直观地定位油气资源的空间分布及其特征,以正确有效地开展部署勘探开发工作,占领市场先机. ...
- 重构31-Replace conditional with Polymorphism(多态代替条件)
多态(Polymorphism)是面向对象编程的基本概念之一.在这里,是指在进行类型检查和执行某些类型操作时,最好将算法封装在类中,并且使用多态来对代码中的调用进行抽象. public class O ...
- 解决VS2010提示warning C4068: 未知的杂注
出现原因是#pragma声明问题,加上#pragma warning(disable:4068)即可 #pragma warning(disable:4068)#pragma execution_ch ...
- 结对项目--黄金点游戏(邓乐&曾亮)
#include<stdio.h> #include<stdlib.h> #include<Windows.h> int result[100][1000000]; ...
- IMX6核心板系列解决方案-工业级|商业级|四核|双核|Plus核心板
i.MX 6Quad四核商业级和工业级系列的应用处理器将可扩展平台与广泛的集成和高能效处理功能相结合,尤其适合多媒体应用.i.MX6 Quad处理器的特性包括: 满足操作系统和游戏的MIPS需求,增强 ...
- vue vueRouter vuex Axios webpack 前端常用内容
Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中.
- git 支持tree命令
由于git 里面是不支持tree命令的 有两种方法可以达到tree的效果 1.使用 winpty tree.com 2.安装tree.exe可执行文件 下载链接: https://sourceforg ...
- Dynamic Web Module版本对应tomcat版本
MyEclipse2017+JDK 1.8环境下 Dynamic Web Module版本3.1要对应tomcat7.0以上版本,不然部署项目时会出现错误(会出现无法部署项目的情况). Dynamic ...
- JavaSE-05 数组
学习要点 数组的基本用法 数组的典型应用 数组相关概念 问题 Java考试结束后,老师给小强分配了一项任务,让他计算全班(30人)的平均分,按照目前的知识结构,如何实现? 问题分析 数组 定义:数组是 ...