lines
lines
Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1375 Accepted Submission(s): 571
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.
1
题意:给你n个区间覆盖x轴,问哪个点被覆盖的线段数多,是几条。
由于数据范围太大,所以离散化……
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm> using namespace std; #define maxn 500008 struct node
{
int op,num;
}P[maxn]; int cmp(node a, node b)
{
return a.op < b.op;
} int main()
{
int t, n, x, y;
scanf("%d", &t);
while(t--)
{
scanf("%d", &n);
int k = 0, j; for(int i = 0; i < n; i++)
{
scanf("%d%d", &x, &y);
P[k].op = x;
P[k++].num = 1;
P[k].op = y+1;
P[k++].num = -1;
}
sort(P, P+k, cmp);
int cnt = 0, Max = 0; for(int i = 0; i < k; )
{
j = i;
while(P[j].op == P[i].op && j < k)
{
cnt += P[j].num;
j++;
} i = j;
Max = max(Max, cnt);
}
printf("%d\n", Max);
}
return 0;
}
lines的更多相关文章
- extracting lines bases a list using awk
extracting lines bases a list using awk awk 'NR==FNR{a[$1]=$0; next}($1 in a){print a[$1]"\n&qu ...
- Enum:Game of Lines(POJ 3668)
画直线 题目大意:给定一些点集,要你找两点之间的连线不平行的有多少条 数据量比较少,直接暴力枚举,然后放到set查找即可 #include <iostream> #include < ...
- 我的常用mixin 之 lines
/** * 最多显示 $lineCount 行 * lines * * example: * @include lines; * @include lines(3); */ @mixin lines( ...
- uva 1471 defence lines——yhx
After the last war devastated your country, you - as the king of the land of Ardenia - decided it wa ...
- POJ 1269 Intersecting Lines --计算几何
题意: 二维平面,给两条线段,判断形成的直线是否重合,或是相交于一点,或是不相交. 解法: 简单几何. 重合: 叉积为0,且一条线段的一个端点到另一条直线的距离为0 不相交: 不满足重合的情况下叉积为 ...
- POJ 1269 Intersecting Lines【判断直线相交】
题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交. 求交点: 这里也用到叉积的原理.假设交点为p0(x0,y0).则有: (p1-p0)X(p2-p0) ...
- [CareerCup] 13.1 Print Last K Lines 打印最后K行
13.1 Write a method to print the last K lines of an input file using C++. 这道题让我们用C++来打印一个输入文本的最后K行,最 ...
- Codeforces 593B Anton and Lines
LINK time limit per test 1 second memory limit per test 256 megabytes input standard input output st ...
- 简单几何(直线位置) POJ 1269 Intersecting Lines
题目传送门 题意:判断两条直线的位置关系,共线或平行或相交 分析:先判断平行还是共线,最后就是相交.平行用叉积判断向量,共线的话也用叉积判断点,相交求交点 /********************* ...
- 【POJ】1269 Intersecting Lines(计算几何基础)
http://poj.org/problem?id=1269 我会说这种水题我手推公式+码代码用了1.5h? 还好新的一年里1A了---- #include <cstdio> #inclu ...
随机推荐
- Kettle的Kitchen和Span
Kitchen——工作(job)执行器 (命令行方式) -rep : Repository name 任务包所在存储名 -user : Repository username 执行人 ...
- C++ Primer: 1. 初识输入和输出
C++没有定义任何的输入和输出语句,而是使用了 标准库来提供IO机制---iostream; 标准库iostream定义了4种不同的IO对象: cin: 标准输入对象:instream类型的对 ...
- HDU 3182 ——A Magic Lamp(思维)
Description Kiki likes traveling. One day she finds a magic lamp, unfortunately the genie in the lam ...
- Codeforces 1156F Card Bag(概率DP)
设dp[i][j]表示选到了第i张牌,牌号在j之前包括j的概率,cnt[i]表示有i张牌,inv[i]表示i在mod下的逆元,那我们可以考虑转移,dp[i][j]=dp[i-1][j-1]*cnt[j ...
- HDU-3714 Error Curves(凸函数求极值)
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- Exchange 2010的部署
实验拓扑: 实验准备条件:计算机基本配置的准备:DC (vbers):配置IP地址.子网掩码.网关EX (vbers2):配置IP地址.子网掩码.网关.指定DNS 域环境搭建的准备1.在计算机名为vb ...
- ios / % 四舍五入 向上取整(ceil()) 向下取整(floor())
1. / //Test "/" cout << "Test \"/\"!" << endl; cout ...
- linux误卸载openssl后的恢复
一.原因 由于在编译mysql时,报ssl错误,于是想卸载openssl再重新安装 rpm -qa|grep openssl rpm -e openssl-.el7_6..x86_64 rpm -e ...
- php关于jquery ajax json不返回数据的问题
分析原因: 1.php端代码有错导致echo输出错误,导致ajax返回函数不执行 2.jquery版本原因 3.juqery前端script代码问题
- css不同情况下的各种居中方法
div水平居中 1.行内元素 .parent{ text-align: center } 2.块级元素 .son{ margin: 0 auto ; } 3.flex布局 .parent{ displ ...