C. Constellation
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

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.

Examples
input
3
0 1
1 0
1 1
output
1 2 3
input
5
0 0
0 2
2 0
2 2
1 1
output
1 3 5
Note

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(计算几何)的更多相关文章

  1. 【CodeForces 618C】Constellation

    题 Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars n ...

  2. CodeForces 618C CodeForces 618C

    第一反应是在凸包上随便找一条边,然后找剩下n-2个点里面距离这条边最短的一个点,这三点就构成了符合要求的三角形..然而..精度被卡死. 换种思路,随便找两个点P1,P2,找剩下n-2个点中哪一个点与P ...

  3. Codeforces Gym100543B 计算几何 凸包 线段树 二分/三分 卡常

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF-Gym100543B.html 题目传送门 - CF-Gym100543B 题意 给定一个折线图,对于每一条 ...

  4. BUPT2017 wintertraining(15) #1 题解

    拖了一周才完成的题解,抛出一个可爱的表情 (っ'-')╮ =͟͟͞͞❤️.对我来说E.F比较难,都是线段树的题,有点久没写了. A - Infinite Sequence CodeForces - 6 ...

  5. 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 ...

  6. Codeforces 749B:Parallelogram is Back(计算几何)

    http://codeforces.com/problemset/problem/749/B 题意:已知平行四边形三个顶点,求另外一个顶点可能的位置. 思路:用向量来做. #include <c ...

  7. 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 ...

  8. Codeforces Round #524 (Div. 2) C. Masha and two friends(思维+计算几何?)

    传送门 https://www.cnblogs.com/violet-acmer/p/10146350.html 题意: 有一块 n*m 的棋盘,初始,黑白块相间排列,且左下角为白块. 给出两个区间[ ...

  9. Codeforces 528E Triangles 3000 - 计算几何

    题目传送门 传送点I 传送点II 传送点III 题目大意 给定$n$的平面上的直线,保证没有三条直线共点,两条直线平行.问随机选出3条直线交成的三角形面积的期望. 显然$S=\frac{1}{2}ah ...

随机推荐

  1. 什么是Entitlement

    Entitlement(权限),可以想象成App里用于描述该App可以调用哪些服务的字符串.苹果的操作系统(mac os或者iOS)会通过检查这个串,决定这个应用是否可以调用相关功能.比如iCloud ...

  2. flex布局以及相关属性

    容器的属性: 父元素设置display:flex:子元素即可使用flex布局. flex-direction 决定项目排列方向: .box { flex-direction: row | row-re ...

  3. Qt_为什么学习Qt

    1)学习GUI编程,市场上任何一款产品几乎都带有图形界面,市场上很火的Androoid.IOS编程无非也是GUI app编程,GUI编程都是差不多的,学习Qt后再学习ANdroid IOS ,那都是S ...

  4. 服务器禁用ping

    linux禁ping.这里操作的是centos6.5内核参数禁ping禁用ping #echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all启用ping ...

  5. 纯html+css中实现静态选座位效果技巧(input+label使用小技巧)

    很多时候,我们想通过html+css的方式实现排列在后方的代码在选中状态下,能控制排列在前的代码的样式.那么要怎么实现呢?在这里我就要用1个小技巧来完成. 众所周知的,我们css中的选择器通常只能向下 ...

  6. 【thinkPHP5实现文件上传】

    上传文件 ThinkPHP5.0对文件上传的支持更加简单. 内置的上传只是上传到本地服务器,上传到远程或者第三方平台的话需要自己扩展. 假设表单代码如下: <form action=" ...

  7. SV学习之interface

    普通的模块使用法:注意我们这里只实现了部分功能....不是完全的读写模块....     module mem_core(   input logic wen,  input logic ren,   ...

  8. Django框架基础知识12-中间件及上下文处理器

    Django中间件(Middleware) 是一个轻量级.底层的“插件”系统,可以介入Django的请求和响应处理过程,修改Django的输入或输出. django 中的中间件(middleware) ...

  9. 记第一次面试的悲惨经历QAQ

    面试岗位:测试开发 自我介绍 :根据介绍的内容,会问简历上涉及到的东西,主要是项目: 手写代码:给一个数组,求数组中所有数字拼接后能得到的最小数字.例:{3,32,312},输出312323. 关于计 ...

  10. LeetCode(71) Simplify Path

    题目 Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/&quo ...