Codeforces 618C(计算几何)
2 seconds
256 megabytes
standard input
standard output
Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position.
In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions.
It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem.
The first line of the input contains a single integer n (3 ≤ n ≤ 100 000).
Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109).
It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line.
Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem.
If there are multiple possible answers, you may print any of them.
3
0 1
1 0
1 1
1 2 3
5
0 0
0 2
2 0
2 2
1 1
1 3 5
In the first sample, we can print the three indices in any order.
In the second sample, we have the following picture.

Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border).
题意:给定一些点,选三个点构成三角形,别的点都在三角形外。
做法:按x为关键字,y为次关键字将所有的点排序,选定1,2两个点,枚举第3个点判断是否能构成三角形。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
struct ss
{
long long x,y,id;
};
inline bool cmp(ss a,ss b)
{
return (a.x<b.x||a.x==b.x&&a.y<b.y);
}
bool check(ss a,ss b,ss c)
{
return 1ll*(c.x-a.x)*(b.y-a.y)-1ll*(c.y-a.y)*(b.x-a.x)!=;
}
int n;
ss a[];
int main()
{
scanf("%d",&n);
int i;
for (i=;i<=n;i++)
scanf("%lld%lld",&a[i].x,&a[i].y),a[i].id=i;
sort(a+,a+n+,cmp);
//for (i=1;i<=n;i++)
// printf("%d %d\n",a[i].x,a[i].y);
for (i=;i<=n;i++)
if (check(a[],a[],a[i]))
{
printf("%lld %lld %lld\n",a[].id,a[].id,a[i].id);
return ;
}
return ;
}
Codeforces 618C(计算几何)的更多相关文章
- 【CodeForces 618C】Constellation
		题 Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars n ... 
- CodeForces 618C CodeForces 618C
		第一反应是在凸包上随便找一条边,然后找剩下n-2个点里面距离这条边最短的一个点,这三点就构成了符合要求的三角形..然而..精度被卡死. 换种思路,随便找两个点P1,P2,找剩下n-2个点中哪一个点与P ... 
- Codeforces Gym100543B 计算几何 凸包 线段树 二分/三分 卡常
		原文链接https://www.cnblogs.com/zhouzhendong/p/CF-Gym100543B.html 题目传送门 - CF-Gym100543B 题意 给定一个折线图,对于每一条 ... 
- BUPT2017 wintertraining(15) #1 题解
		拖了一周才完成的题解,抛出一个可爱的表情 (っ'-')╮ =͟͟͞͞❤️.对我来说E.F比较难,都是线段树的题,有点久没写了. A - Infinite Sequence CodeForces - 6 ... 
- Codeforces Round #335 (Div. 1) C. Freelancer's Dreams 计算几何
		C. Freelancer's Dreams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contes ... 
- Codeforces 749B:Parallelogram is Back(计算几何)
		http://codeforces.com/problemset/problem/749/B 题意:已知平行四边形三个顶点,求另外一个顶点可能的位置. 思路:用向量来做. #include <c ... 
- Codeforces Round #339 (Div. 1) A. Peter and Snow Blower 计算几何
		A. Peter and Snow Blower 题目连接: http://www.codeforces.com/contest/613/problem/A Description Peter got ... 
- Codeforces Round #524 (Div. 2) C. Masha and two friends(思维+计算几何?)
		传送门 https://www.cnblogs.com/violet-acmer/p/10146350.html 题意: 有一块 n*m 的棋盘,初始,黑白块相间排列,且左下角为白块. 给出两个区间[ ... 
- Codeforces 528E Triangles 3000 - 计算几何
		题目传送门 传送点I 传送点II 传送点III 题目大意 给定$n$的平面上的直线,保证没有三条直线共点,两条直线平行.问随机选出3条直线交成的三角形面积的期望. 显然$S=\frac{1}{2}ah ... 
随机推荐
- Oracle创建用户及权限设置
			oracle用户创建及权限设置 权限: create session create table unlimited tablespace connect resource dba 例: #sqlplu ... 
- FPGA-信号边缘检测
			在FPGA逻辑电路中,输入信号的边缘检测是一个常用的操作,这算是FPGA的基本功之一. 信号边缘检测应用十分广泛,例如:通信协议的时序操作,按键的检测等,都应用到按键的检测.按键的检测分为上升沿和下降 ... 
- mysql 表锁死的问题
			select * from information_schema.innodb_trx; kill 34863;kill 34856;kill 34860;kill 34859;kill 34845; ... 
- m3u8 格式转MP4
			现在很多视频网站采用HLS流媒体的方式来提供视频直播,在HTML源代码中flash的播放地址为 http://xxxxxx/video/movie.m3u8 1.m3u8下载的格式大致如下: #EXT ... 
- vueshengmingzhouqi
			首先,每个Vue实例在被创建之前都要经过一系列的初始化过程,这个过程就是vue的生命周期.首先看一张图吧~这是官方文档上的图片相信大家一定都会很熟悉: 可以看到在vue一整个的生命周期中会有很多钩子函 ... 
- 12.	KEY_COLUMN_USAGE
			12. KEY_COLUMN_USAGE KEY_COLUMN_USAGE表描述哪些键列具有约束. KEY_COLUMN_USAGE表有以下列: CONSTRAINT_CATALOG :约束所属目录的 ... 
- 如何用 CSS 创作一个立体滑动 toggle 交互控件
			效果预览 在线演示 按下右侧的"点击预览"按钮在当前页面预览,点击链接全屏预览. https://codepen.io/zhang-ou/pen/zjoOgX 可交互视频教程 此视 ... 
- JavaScript基础对象---Map
			一.创建Map对象 Map 对象保存键值对.任何值(对象或者原始值) 都可以作为一个键或一个值 1.构造函数 语法:new Map([iterable])参数: iterable 可 ... 
- 【51nod 1092】 回文字符串(区间DP)
			回文串是指aba.abba.cccbccc.aaaa这种左右对称的字符串.每个字符串都可以通过向中间添加一些字符,使之变为回文字符串. 例如:abbc 添加2个字符可以变为 acbbca,也可以添加3 ... 
- [Noip2017][Day 1][T1]玩具谜题(toy.cpp)
			题目描述 小南有一套可爱的玩具小人, 它们各有不同的职业. 有一天, 这些玩具小人把小南的眼镜藏了起来. 小南发现玩具小人们围成了一个圈,它们有的面朝圈内,有的面朝圈外.如下图: 这时singer告诉 ... 
