Description

  在xoy直角坐标平面上有n条直线L1,L2,...Ln,若在y值为正无穷大处往下看,能见到Li的某个子线段,则称Li为
可见的,否则Li为被覆盖的.
例如,对于直线:
L1:y=x; L2:y=-x; L3:y=0
则L1和L2是可见的,L3是被覆盖的.
给出n条直线,表示成y=Ax+B的形式(|A|,|B|<=500000),且n条直线两两不重合.求出所有可见的直线.

Input

  第一行为N(0 < N < 50000),接下来的N行输入Ai,Bi

Output

  从小到大输出可见直线的编号,两两中间用空格隔开,最后一个数字后面也必须有个空格

Sample Input

3
-1 0
1 0
0 0

Sample Output

1 2

Solution

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MAXN 50010
#define Eps 1e-18 using namespace std; struct Liyn{
int k, b, pos; void Push(int i) {scanf("%d%d", &k, &b); pos = i;} bool operator == (const Liyn &a)const {return k == a.k;} bool operator < (const Liyn &a)const {return k < a.k || (k == a.k && b > a.b);} double Cmp(const Liyn &a) {return double(a.b - b) / double(k - a.k);}
}L[MAXN], _pb[MAXN]; int n, top, ans[MAXN]; int main(){
scanf("%d", &n);
for(int i = ; i < n; i++)
L[i].Push(i);
sort(L, L + n);
n = unique(L, L + n) - L;
for(int i = ; i < n; i++){
while(top > && _pb[top - ].Cmp(_pb[top - ]) > L[i].Cmp(_pb[top - ]) - Eps)top--;
_pb[top++] = L[i];
}
for(int i = ; i < top; i++)
ans[i] = _pb[i].pos;
sort(ans, ans + top);
for(int i = ; i < top; i++)
printf("%d ", ans[i] + );
return ;
}

最新文章

  1. linux下安装apache与php;Apache+PHP+MySQL配置攻略
  2. 删除项目中的CocoaPods
  3. 缺陷管理系统mantisbt环境搭建
  4. 使用Guava来计算笛卡尔积
  5. 安装shopex注意事项
  6. 虚函数(virtual)为啥不能是static
  7. socket的accept函数解析
  8. m个苹果放入n个盘子问题
  9. .Net Core下使用WCF
  10. 学习Object.assign()
  11. Windows zip安装MySQL
  12. Ajax.html:35 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user&#39;s experience. For more help, check https://xhr.spec.whatwg.org
  13. Oracle EBS SLA 详解
  14. 程序员十大热门flag,有你的吗?
  15. [Kubernetes]深入解析Pod对象
  16. python安装多版本
  17. 关于Python课程的一些思考。
  18. 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(浙江省赛2015)
  19. WIN10护眼色
  20. 禁止用键盘左右箭头,去切换PageControl页签

热门文章

  1. 设计模式(十三):从“FQ”中来认识代理模式(Proxy Pattern)
  2. 【NLP】揭秘马尔可夫模型神秘面纱系列文章(三)
  3. Oracle数据加载之外部表的介绍
  4. 你真的会玩SQL吗?三范式、数据完整性
  5. Redis简单案例(一) 网站搜索的热搜词
  6. Java语言中的面向对象特性总结
  7. AOP的实现原理
  8. offset、client、scroll开头的属性归纳总结
  9. Maven对插件进行全局设置
  10. SSH远程会话管理工具 - screen使用教程