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 ...
随机推荐
- C++库研究笔记——Linux下是否需要使用memory pool?
Linux Slab分配器(一)--概述 Linux slab 分配器剖析 C++库研究笔记——内存池实现 做了一些测试:发现linux使用内存池与否没有明显差别,仅仅有2倍. Linux内存处理机制 ...
- Java基础知识强化之集合框架笔记02:集合的继承体系图解
1. 集合的继承体系图解:
- Java设计模式---组合模式
一.组合模式定义 组合模式定义: Compose objects into tree structures to represent part-whole hierarchies. Composite ...
- tomcat startup.sh提示java.lang.OutOfMemoryError: PermGen space
JAVA_OPTS="-server -XX:PermSize=512M -XX:MaxPermSize=1024m"if [ -z "$LOGGING_MANAGER& ...
- 不容错过的20段CSS代码
Web开发技术每年都在革新,浏览器已逐渐支持CSS3特性,并且网站设计师和前端开发者普遍采用这种新技术进行设计与开发.但仍然有一些开发者迷恋着一些CSS2代码. 分享20段非常专业的CSS2/CSS3 ...
- 结束指定Activity实例代码
开通博客两个多月了,一直在看你们的文章 终于发觉伸手党真的很可耻.. 于是就随便写了个Demo来结束伸手党生涯~ Demo很简单:结束指定Activity... 不过也是我的一个小心意嘛.. 不要责怪 ...
- wininet API调用,检测网络
[DllImport("wininet")] private extern static bool InternetGetConnectedState(out int ...
- Skin++ 皮肤库 CCheckListBox MFC 界面风格
今天使用CCheckListBox,发现增加进去的字符串无法显示,但是当点击的时候,确有反应. 仔细检查代码,没有问题.之前也是这样用的,完全没有问题. 思前想后,觉得是因为使用了Skin++皮肤库, ...
- osg for android (一) 简单几何物体的加载与显示
1. 首先需要一个OSG for android的环境. (1).NDK 现在Eclipse 对NDK已经相当友好了,已经不需要另外cygwin的参与,具体可以参考 Android NDK开发篇(一) ...
- Smtp协议与Pop3协议的简单实现
前言 本文主要介绍smtp与pop3协议的原理,后面会附上对其的简单封装与实现. smtp协议对应的RFC文档为:RFC821 smtp协议 SMTP(Simple Mail Transfer Pro ...