凸包 点积 Tavas and Pashmaks:CodeForces 535E
来源:互联网 发布:阿普利亚200圣甲虫数据 编辑:程序博客网 时间:2024/06/06 01:43
题目:CodeForces 535E
time limit per test1 second
memory limit per test256 megabytes
Tavas is a cheerleader in the new sports competition named “Pashmaks”.
This competition consists of two part: swimming and then running. People will immediately start running R meters after they finished swimming exactly S meters. A winner is a such person that nobody else finishes running before him/her (there may be more than one winner).
Before the match starts, Tavas knows that there are n competitors registered for the match. Also, he knows that i-th person’s swimming speed is si meters per second and his/her running speed is ri meters per second. Unfortunately, he doesn’t know the values of R and S, but he knows that they are real numbers greater than 0.
As a cheerleader, Tavas wants to know who to cheer up. So, he wants to know all people that might win. We consider a competitor might win if and only if there are some values of R and S such that with these values, (s)he will be a winner.
Tavas isn’t really familiar with programming, so he asked you to help him.
Input
The first line of input contains a single integer n (1 ≤ n ≤ 2 × 10^5).
The next n lines contain the details of competitors. i-th line contains two integers si and ri (1 ≤ si, ri ≤ 10^4).
Output
In the first and the only line of output, print a sequence of numbers of possible winners in increasing order.
Examples
input
3
1 3
2 2
3 1
output
1 2 3
input
3
1 2
1 1
2 1
output
1 3
题意
有N(N<=2*10^5)名选手参加两场比赛,先游泳后跑步。告诉你每名选手的游泳速度si和跑步速度ri,问哪些选手有可能赢得比赛(泳道和跑道长度未知)。
思路:
假设泳道长度为S,跑道长度为R,则
解法1:
由于1 ≤ si, ri ≤ 10^4,我们可以通过预处理将选手减少到10^4个,然后来个N^2大暴力。
解法2:
题解中的做法是把(ri,si)看成一个个的点,用这些点求凸包,答案就是凸包上从最左到最下(逆时针)的所有点。
为什么呢?
把(R,S)看做向量,每个人所用的时间就是他们所代表的点(ri,si)与这个向量点乘的结果,也就是在这个向量上的投影,那么凸包里面的肯定不如凸包外面的优,右上的肯定不如左下的优。见下图:
对于任意的向量(R,S),显然与他垂直并且相切在凸包上的点的点积是最小的。所以向量(R,S)在从x轴变化到y轴的过程中。对应的凸包上的切线就是从y轴变化到x轴,这些切线上的点就是凸包的外围点。而且显然靠近坐标原点O的更优。即下图的红线部分。
代码:待补充
- 凸包 点积 Tavas and Pashmaks:CodeForces 535E
- codeforces 536 c Tavas and Pashmaks
- cf-535C Tavas and Pashmaks
- Codeforces Round #299 (Div. 1)C. Tavas and Pashmaks
- Codeforces 535C Tavas and Karafs(二分)
- Codeforces 535C Tavas and Karafs
- CodeForces 535B — Tavas and SaDDas
- [Codeforces 535B]Tavas and Karafs
- codeforces 535B-Tavas and SaDDas
- Codeforces 535C Tavas and Karafs(二分)
- CodeForces 535C Tavas and Karafs
- CodeForces 535C Tavas and Karafs
- Codeforces-535B Tavas and SaDDas
- 二分 Tavas and Karafs:CodeForces 535C
- KMP Tavas and Malekas:CodeForces 535D
- Codeforces 535C : Tavas and Karafs(二分)
- Codeforces 535C Tavas and Karafs(二分)
- CodeForces 535C Tavas and Karafs
- 多进程、多线程调试
- goEasy消息推送,pushlet 向特写用户实时推送
- IC设计基础系列之低功耗篇4:(数字IC)低功耗设计入门(四)——RTL级低功耗设计
- Android学习笔记2-1--组件3--Reciver
- 判断浏览器移动端
- 凸包 点积 Tavas and Pashmaks:CodeForces 535E
- ES6之babel
- Android学习笔记2-1--组件4--Service
- leetCode 49 Group Anagrams
- OBS bit rate推流比特率最佳设置
- 关于网站易用性理解
- 通过 Apache 代理访问 NodeJS 服务
- 【Docker】Docker的简介
- C# 中的委托和事件