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 ...
随机推荐
- Php面向对象 – 单例模式
Php面向对象 – 单例模式 保证类仅仅有一个实例 1. 怎样能够解决一个类能够被无限地实例化? New,就能实例化一次,怎么去限制,用户不能无限次地new? 将构造方法私有化.全部外部的new ...
- Cocos2d-x 3.x 头像选择,本地相册图片+图片编辑(Android、IOS双平台)
大连游戏产业不是很发达,最后,选择一个应用程序外包公司.积累的工作和学习过程中的一点业余生活微信体验,我想分享的游戏小朋友的爱. 在应用开发过程中会经常实用户上传头像的功能,在网上找了N多资料发现没有 ...
- PHP 将Base64图片保存到 Sae storage
<?php $file_dir='tu/'.date("Y/m/d").'/'; $fileName=create_guid(); $storage = new SaeSto ...
- 线段树---HDU2795Billboard
这道题跟第二个题差不多,求单点的最大值. 题目大意:有个高和宽分别为h, w的广告牌, 这个广告牌分成高为 1 的长条, 每条分别能贴长度为wi长度的广告, 输入的n为广告的条数,广告优先贴在最上边和 ...
- ClickOnce发布后不能安装
当在internet发布用ClickOnce打包的客户端程序时,遇到ClickOnce启动后出错,错误信息如下: + Downloading https://xxxxx/Deploy/pc/Boote ...
- jQuery中使用 .html() function在IE8和9中显示不正常源码中多出sizset和sizcache
错误原因:在引入jquery的时候,使用了html function,在IE8和IE9下面有可能会出现不兼容 解决办法:在html头部加一句 <meta http-equiv="X-U ...
- Ubuntu 11.10 安装GMONE3,卸载 UNITY和UNITY 2D
Ubuntu 11.10安装GNOME3: 1)sudo apt-get install gnome-shell sudo apt-get install gnome-themes* (或者 ...
- web项目环境搭建(1):建立一个maven项目
一.maven简介以及常用概念 1.Maven是一个项目管理和整合的工具.Maven为开发者提供了一套完整的构建生命周期框架.开发团队基本不用花多少时间就能自动完成工程的基础构建配置,因为Maven使 ...
- 启动mySQL安装出现1067错误
可能几种的办法: 删除data目录下的ib_logfile0和ib_logfile1 查看my.ini文件中的dir设置 查看err文件,如果是temp出现错误文件,则添加temp文件的路径
- 高放的c++学习笔记之重载运算与类型转换
▲基本概念 (1)重载运算符是具有特殊名字的函数,它们的名字又operator和其后要定义的运算符号共同构成.. (2)对于一个运算符号来说它或者是类的成员,或者至少含有一个类类型的参数. (3)我们 ...