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. PL/SQL学习笔记(三)

    -----创建一个序列,再创建一个表(主键是数字),通过序列生成该表的主键值. create table mytb1( m_id number primary key, m_name ) not nu ...

  2. 第一次提交代码到github时经常遇到的问题

    最近两年在OpenStack方面做了一些工作,写了一些实验性的plugin. 本着Open Source的共享精神,想尝试提交到github,以便他人能下载使用. 当你注册完github帐号之后,点击 ...

  3. ubuntu服务器切换语言

    如果在安装Ubuntu Server时选择了中文,在系统安装完毕后,默认是中文,在操作时经常会显示乱码,如果需要设置回英文,则修改/etc/default/locale,将 LANG="cn ...

  4. PHP一句话后门过狗姿势万千之传输层加工

    既然木马已就绪,那么想要利用木马,必然有一个数据传输的过程,数据提交是必须的,数据返回一般也会有的,除非执行特殊命令. 当我们用普通菜刀连接后门时,数据时如何提交的,狗狗又是如何识别的,下面结合一个实 ...

  5. zk伪集群部署

    jdk 配置 # tar xf jdk-8u161-linux-x64.tar.gz -C /usr/local/ # vim /etc/profile.d/jdk.sh export JAVA_HO ...

  6. OpenCV2:第五章 访问图像

    一.行/列访问 1.单行/单列访问 Mat Mat::row(int i) const Mat Mat::col(int j) const 2.多行/多列访问 Range(start,end); Ra ...

  7. 洛谷——P4932 浏览器

    P4932 浏览器 __stdcall给了你n个点,第i个点有权值x[i],对于两个点u和v,如果x[u] xor x[v]的结果在二进制表示下有奇数个1,那么在u和v之间连接一个Edge,现在__s ...

  8. Linux环境下挂载SD卡的教程

    1.插入SD卡 如果系统能够识别SD卡,则会打印一些信息: 2.查看系统给SD卡分配的设备名 命令如下: fdisk -l 命令 说明:通常是根据SD卡的存储容量来确定的. 比如下面的信息: 3.挂载 ...

  9. ZOJ - 1655 Transport Goods(单源最长路+迪杰斯特拉算法)

    题目: 有N-1个城市给首都(第N个城市)支援物资,有M条路,走每条路要耗费一定百分比(相对于这条路的起点的物资)的物资.问给定N-1个城市将要提供的物资,和每条路的消耗百分比.求能送到首都的最多的物 ...

  10. 洛谷P1035 级数求和

    #include <iostream> using namespace std; int main(){ long k,i; cin >> k; double s=0.0; ; ...