Codeforces Round #299 (Div. 1)C. Tavas and Pashmaks (凸壳)
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.
The first line of input contains a single integer n (1 ≤ n ≤ 2 × 105).
The next n lines contain the details of competitors. i-th line contains two integers si and ri (1 ≤ si, ri ≤ 104).
In the first and the only line of output, print a sequence of numbers of possible winners in increasing order.
3
1 3
2 2
3 1
1 2 3
3
1 2
1 1
2 1
1 3 题意:n个人比赛,游泳和赛跑,游泳距离S,赛跑R。 每个人对应两个速度(陆地和水上的), 如果存在 S , R,使得第i个人胜利,那么输出i。
题目要求 :输出所有的i。
可以把 ri si的倒数看成坐标系上的点,时间可以当做 两个向量的点积也就是投影。。。
求出凸包。 p1 为最下面的点如果有多个选取最左面的那个, p2位最左面的点如果有多个选取最下面的那个。 那么凸包上从p1到p2的点必然满足题意。注意判重
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-;
const int inf = 0x3f3f3f3f;
struct Point
{
double x, y;
int idx;
Point (double x = , double y = ):
x(x), y(y) {}
bool operator == (const Point &rhs)const
{
return abs(x - rhs.x) < eps && (y - rhs.y) < eps;
}
bool operator < (const Point &rhs) const
{
return x < rhs.x || (abs(x-rhs.x) < eps && y < rhs. y);
}
};
typedef Point Vector;
Vector operator - (Point p1, Point p2)
{
return Vector (p1.x-p2.x, p1.y-p2.y);
}
double Cross(Vector p1, Vector p2)
{
return p1.x*p2.y - p2.x*p1.y;
}
Point p[], cvx[];
bool ans[];
int pos[];
bool cmp(double x)
{
return x < || abs(x) < eps;
}
int ConvexHull(int n)
{
sort (p, p+n);
// n = unique(p, p+n) - p;
int tot = ;
for (int i = ; i < n; i++)
{
if (i > && p[i] == p[i-])
{
pos[i] = pos[i-];
continue;
}
pos[i] = i;
while (tot > && cmp(Cross(cvx[tot-]-cvx[tot-], p[i]-cvx[tot-])) == true)
tot--;
cvx[tot++] = p[i];
}
int k = tot;
for (int i = n-; i >= ; i--)
{
while (tot > k && cmp(Cross(cvx[tot-]-cvx[tot-],p[i]-cvx[tot-]) == true))
tot--;
cvx[tot++] = p[i];
}
if (n > )
tot--;
return tot;
}
bool cmp2(const Point &p1, const Point &p2)
{
return p1.y < p2.y || (abs(p1.y-p2.y) < eps && p1.x < p2.x);
}
int main(void)
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
int n;
while (~scanf ("%d", &n))
{
memset(ans, false, sizeof(ans));
memset(pos, , sizeof(pos));
double minv1 = inf, minv2 = inf;
for (int i = ; i < n; i++)
{
double s, r;
scanf ("%lf%lf", &s, &r);
minv1 = min(/r, minv1); //减小误差
minv2 = min(minv2, /s);
p[i] = Point(/s, /r);
p[i].idx = i;
}
int tot = ConvexHull(n);
for (int i = ; i < tot; i++)
{
ans[cvx[i].idx] = true;
if (abs(cvx[i].y-minv1) < eps)
break;
}
for (int i = ; i < n; i++)
{
if (ans[p[pos[i]].idx] == true)
ans[p[i].idx] = true;
}
for (int i = ; i < n; i++)
if (ans[i] == true)
printf("%d ", i+);
printf("\n"); } return ;
}
Codeforces Round #299 (Div. 1)C. Tavas and Pashmaks (凸壳)的更多相关文章
- 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs
题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
- DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas
题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...
- Codeforces Round #299 (Div. 2) D. Tavas and Malekas kmp
题目链接: http://codeforces.com/problemset/problem/535/D D. Tavas and Malekas time limit per test2 secon ...
- Codeforces Round #299 (Div. 1) A. Tavas and Karafs 水题
Tavas and Karafs Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/536/prob ...
- Codeforces Round #299 (Div. 2) B. Tavas and SaDDas 水题
B. Tavas and SaDDas Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/p ...
- Codeforces Round #299 (Div. 2) A. Tavas and Nafas 水题
A. Tavas and Nafas Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/pr ...
- Codeforces Round #299 (Div. 2) B. Tavas and SaDDas【DFS/*进制思维/位运算/一个数为幸运数,当且仅当它的每一位要么是4,要么是7 ,求小于等于n的幸运数个数】
B. Tavas and SaDDas time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #299 (Div. 2)D. Tavas and Malekas
KMP,先预处理按每个节点标记,扫一遍更新每个匹配位置,最后kmp判断是否有重合而且不相同的地方 注意处理细节,很容易runtime error #include<map> #includ ...
随机推荐
- 用shape结合selector实现点击效果
<span style="font-family:Arial, Helvetica, sans-serif;font-size:18px;background-color: rgb(2 ...
- mysql将一个库中表的某几个字段插入到另一个库中的表
insert into dbname1.tablename1(filed1,filed2,filed3) select filed1,filed2,filed3from dbname2.tablena ...
- C#导出数据到Excel通用的方法类
导出数据到Excel通用的方法类,请应对需求自行修改. 资源下载列表 using System.Data; using System.IO; namespace IM.Common.Tools { p ...
- sass笔记-4|像写脚本一样写Sass,把能交给Sass办的都交给它
Sass笔记关于sass的基础部分已经写完,这一篇介绍Sass的高级特性--脚本特性.Sass能做很多事让样式表更智能,我们先会看到Sass眼中的数据类型,在这些数据类型上会有可进行的操作,此外,Sa ...
- 小学生之SpringMVC
1. Springmvc是什么? Spring Web MVC是一种基于Java的实现了Web MVC设计模式的请求驱动类型的轻量级Web框架,即使用了MVC架构模式的思想,将web层进行职责解耦,基 ...
- adb服务无法启动
今天学习android编程发现调试出错 The connection to adb is down, and a severe error has occured. You must restart ...
- N!水题
//题目是求N!的问题,思路:设定一个整形数组来存放每次计算过后的值 有两个for循环,第一个for循环每次加进一个数 然后在第二个for循环里面计算出此时的阶乘,比如9999,先给出i=2 在第二个 ...
- 2015-09-28 Javascript
1.Javascript是什么? JavaScript是一种脚本语言,结构简单,使用方便,其代码可以直接放入HTML文档中,可以直接在支持JavaScript的浏览器中运行.JavaSript. Ja ...
- oracle的一知半解
这里只讲第一次开发运用oracle数据库的.net程序遇到问题: 1.程序与oracle数据库在同一台的服务器,貌似设置好连接字符串就可以直接访问( 需要主要的问题: 字符串格式:Data Sourc ...
- ASP.NET获取根目录的方法集合
编写程序的时候,经常需要用的项目根目录,自己总结如下: 1.取得控制台应用程序的根目录方法 方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径 方法 ...