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 ...
随机推荐
- Android ArrayAdapter MultiAutoCompleteTextView
MultiAutoCompleteTextView 继承自AutoCompleteTextView,它和AutoCompleteTextView不同的就是能处理多个输入字段,如发送短信界面的联系人列表 ...
- 指针-->字符串
1. 以字符串形式出现的,编译器都会为该字符串自动添加一个0作为结束符. 如在代码中写"abc",那么编译器帮你存储的是"abc\0". 2. "ab ...
- C#中将图片文件转化为二进制数组-用于数据库存储
在项目开发中,使用SQL Server存储数据,数据类型image可以保存图片.但是在存储之前需要将图片转化为二进制数组的形式进行赋值. 将图片文件转换为二进制数组 /// <summary&g ...
- Java基础知识强化25:Java创建对象的四种方式
1. Java程序中对象的创建有四种方式: ● 调用new语句创建对象,最常见的一种 ● 运用反射手段创建对象,调用java.lang.Class 或者 java.lang.reflect.Const ...
- 95秀-自定义对话框 dialog 合集
普通的确认对话框 NormalDialog.java import android.app.Dialog; import android.content.Context; import android ...
- 利用ParameterizedType获取泛型参数类型
//利用ParameterizedType获取java泛型的参数类型 public class Demo { public static void main(String[] args) { ...
- ASP.NET-FineUI开发实践-6(三)
自动补全也算是好东西吧,我也不清楚下拉列表可以过滤为啥还有自动补全,其实自动补全用到还是通过jq获取服务端的动态数据补全.我没做动态的例子,其实好写,就不写了. 1.用到了两个js包 <scri ...
- AndroidSdk下载地址和环境变量配置
一.Android Studio 下的AndroidSdk下载地址 http://tools.android-studio.org/index.php/sdk 二.Android Sdk环境变量设置 ...
- android获取在res文件下的图片资源
//得到该图片的id(name 是该图片的名字,"drawable" 是该图片存放的目录,getPackageName()是应用程序的包) int resID = getResou ...
- 系统管理中 bash shell 脚本常用方法总结
在日常系统管理工作中,需要编写脚本来完成特定的功能,编写shell脚本是一个基本功了!在编写的过程中,掌握一些常用的技巧和语法就可以完成大部分功能了,也就是2/8原则 1. 单引号和双引号的区别 单引 ...