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 ...
随机推荐
- tree_cuttting(树形dp求解树的重心)
Tree Cutting After Farmer John realized that Bessie had installed a "tree-shaped" network ...
- [LeetCode] 矩形面积
题目链接: https://leetcode-cn.com/problems/rectangle-area 难度:中等 通过率:41.3% 题目描述: 在 二维 平面上计算出两个 由直线构成的 矩形重 ...
- 微信小程序的拖拽、缩放和旋转手势
在开发中,有时会遇到像App中的手势那样的效果,下面就仿照App实现了一下. wxml部分: <view class="touch-container"> <vi ...
- java使用Callable创建又返回值的线程
并发编程使我们可以将程序分为很多个分离的,相互之间独立的任务,通过使用多线程的机制,将每个任务都会有一个执行线程来单独的驱动,一个线程是 进程中一个单一顺序控制流,一个进程可以拥有多个线程,也就相当于 ...
- vim学习(三)之命令
参考 Linux vi/vim vim常用命令总结
- 运维LVS-NAT模式理解
一.LVS-NAT模式的工作原理这个是通过网络地址转换的方法来实现调度的.首先调度器(LB)接收到客户的请求数据包时(请求的目的IP为VIP),根据调度算法决定将请求发送给哪个 后端的真实服务器(RS ...
- PHP trait与单例模式 (一次编写,到处使用)
一 trait php是单继承的语言,无法同时从两个基类中继承属性和方法,为了解决这个问题,php出了Trait这个特性. 个人理解的trait是: trait = abstract class - ...
- jse中将数据反转
public class test { public static void main(String args[]){ String arr[]={"1","2" ...
- Echarts-主题切换
从网上搜索了相关的方法,是主题之前的切换,但是用的是下拉框类型的,也可以设置div样式,参考官网那种 设置一个div,通过三个图片的点击效果实现切换主题的功能 我用的jQuery和Echarts是cd ...
- 【检测工具】keepalived安装及配置
一.keepalived安装 keepalived是一个检测服务器状态的脚本,在高可用机制上经常可以看到它的身影. 在Linux中安装keepalived: 1.在网上直接下载相应的压缩包,推荐链接 ...