Problem Description
John has several lines. The lines are covered on the X axis. Let A is a point which is covered by the most lines. John wants to know how many lines cover A.
 
Input
The first line contains a single integer T(1≤T≤100)(the data for N>100 less than 11 cases),indicating the number of test cases.
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.
 
Output
For each case, output an integer means how many lines cover A.
 
Sample Input
2
5
1 2
2 2
2 4
3 4
5 1000
5
1 1
2 2
3 3
4 4
5 5
 
Sample Output
3
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(区间处理 +离散化)的更多相关文章

  1. POJ-2528 Mayor's posters (线段树区间更新+离散化)

    题目分析:线段树区间更新+离散化 代码如下: # include<iostream> # include<cstdio> # include<queue> # in ...

  2. POJ 2528 Mayor's posters (线段树+区间覆盖+离散化)

    题意: 一共有n张海报, 按次序贴在墙上, 后贴的海报可以覆盖先贴的海报, 问一共有多少种海报出现过. 题解: 因为长度最大可以达到1e7, 但是最多只有2e4的区间个数,并且最后只是统计能看见的不同 ...

  3. HDU5124:lines(线段树+离散化)或(离散化思想)

    http://acm.hdu.edu.cn/showproblem.php?pid=5124 Problem Description John has several lines. The lines ...

  4. POJ 2528 Mayor's posters(线段树/区间更新 离散化)

    题目链接: 传送门 Mayor's posters Time Limit: 1000MS     Memory Limit: 65536K Description The citizens of By ...

  5. POJ 2528 Mayor's posters(线段树区间染色+离散化或倒序更新)

    Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 59239   Accepted: 17157 ...

  6. poj-----(2528)Mayor's posters(线段树区间更新及区间统计+离散化)

    Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 43507   Accepted: 12693 ...

  7. POJ2528:Mayor's posters(线段树区间更新+离散化)

    Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral electio ...

  8. 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 ...

  9. POJ-2528 Mayor's posters(线段树区间更新+离散化)

    http://poj.org/problem?id=2528 https://www.luogu.org/problem/UVA10587 Description The citizens of By ...

  10. hiho一下21周 线段树的区间修改 离散化

    离散化 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho在回国之后,重新过起了朝7晚5的学生生活,当然了,他们还是在一直学习着各种算法~ 这天小Hi和小Ho ...

随机推荐

  1. SQL快速备份

    ALTER  PROCEDURE [dbo].[usp_Backup_DataBase]    (      @BackupDataBaseName VARCHAR(128)    )AS    BE ...

  2. 纯CSS写的对勾样式

    & .cicle{          position: relative;          float: right;          margin-right: -1rem;      ...

  3. javascript中函数的四种调用模式详解

    介绍函数四种调用模式前,我们先来了解一下函数和方法的概念,其实函数和方法本质是一样,就是称呼不一样而已.函数:如果一个函数与任何对象关系,就称该函数为函数.方法:如果一个函数作为一个对象属性存在,我们 ...

  4. IntelliJ IDEA导入JDK出现The selected directory is not a valid home for JDK问题的解决方法

    JDK版本与IDEA版本不兼容: JDK版本过高可能会造成这个问题,需与IDEA相兼容的JDK才行. 比如,用IDEA2016.3.8版本的,JDK用jdk-10.0.1_windows-x64_bi ...

  5. js 日期时间大小比较

    <body> 开始时间:<input onfocus="setday(this)" id="startTime" name="sta ...

  6. codeforces_B. Forgery

    http://codeforces.com/contest/1059/problem/B 题意: For simplicity, the signature is represented as an  ...

  7. A C compiler that parses this code will contain at least the following symbol table entries

    A C compiler that parses this code will contain at least the following symbol table entries Consider ...

  8. arcpy利用XY创建点

    # -*- coding: utf-8 -*-"""Created on Sun Apr 7 15:32:24 2019@author: ""&quo ...

  9. CAD交互绘制样条线(com接口)

    在CAD设计时,需要绘制样条线,用户可以设置样条线线重及颜色等属性. 主要用到函数说明: _DMxDrawX::SendStringToExecuteFun 把命令当着函数执行,可以传参数.详细说明如 ...

  10. Java C

    先说一下自己叫什么,免得面试的人张冠李戴. 介绍自己有几个方面:1学什么专业的那方面学的过硬,可以说的具体点. 2以前做过什么.(这家公司要你肯定是和你的经历有关.) 3现在来这家公司的目的是什么(当 ...