第一反应是在凸包上随便找一条边,然后找剩下n-2个点里面距离这条边最短的一个点,这三点就构成了符合要求的三角形。。然而。。精度被卡死。

换种思路,随便找两个点P1,P2,找剩下n-2个点中哪一个点与P1,P2形成的三角形面积最小,这三点构成了符合要求的三角形,然而我没写。。

最终这样写的,按X,Y进行排序,相邻三个判断是否三点共线即可

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std; const int maxn=+;
vector<int>v[maxn];
struct point
{
int px,y;
int x;
int id;
}p[maxn];
int n;
int lshx[maxn]; bool cmp(const point&a,const point&b)
{
if(a.px==b.px) return a.y<b.y;
return a.px<b.px;
} bool cmp1(const point&a,const point&b)
{
return a.id<b.id;
} long long multiply(point sp,point ep,point op)
{
long long a=(long long)(sp.px-op.px);
long long b=(long long)(ep.y-op.y);
long long c=(long long)(ep.px-op.px);
long long d=(long long)(sp.y-op.y); return a*b-c*d;
} int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d%d",&p[i].px,&p[i].y);
p[i].id=i;
}
sort(p+,p++n,cmp);
int tot=;
p[].x=tot;
for(int i=;i<=n;i++)
{
if(p[i].px==p[i-].px) p[i].x=p[i-].x;
else
{
tot++;
p[i].x=tot;
}
} for(int i=;i<=n;i++) v[p[i].x].push_back(p[i].id);
sort(p+,p++n,cmp1);
if(v[].size()>=)
{
printf("%d %d ",v[][],v[][]);
printf("%d\n",v[][]);
}
else if(v[].size()>=)
{
printf("%d ",v[][]);
printf("%d %d\n",v[][],v[][]);
}
else
{
for(int i=;i<=tot;i++)
{
if(v[i].size()>=)
{
printf("%d ",v[i-][]);
printf("%d %d\n",v[i][],v[i][]);
break;
}
else
{
if(multiply(p[v[i][]],p[v[i-][]],p[v[i-][]])==) continue;
else
{
printf("%d %d %d\n",v[i][],v[i-][],v[i-][]);
break;
}
}
}
}
return ;
}

CodeForces 618C CodeForces 618C的更多相关文章

  1. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  2. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  3. codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers

    题目链接:http://codeforces.com/problemset/problem/616/A 题目意思:顾名思义,就是比较两个长度不超过 1e6 的字符串的大小 模拟即可.提供两个版本,数组 ...

  4. codeforces Educational Codeforces Round 16-E(DP)

    题目链接:http://codeforces.com/contest/710/problem/E 题意:开始文本为空,可以选择话费时间x输入或删除一个字符,也可以选择复制并粘贴一串字符(即长度变为两倍 ...

  5. Codeforces Educational Codeforces Round 15 E - Analysis of Pathes in Functional Graph

    E. Analysis of Pathes in Functional Graph time limit per test 2 seconds memory limit per test 512 me ...

  6. Codeforces Educational Codeforces Round 15 D. Road to Post Office

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  7. Codeforces Educational Codeforces Round 15 C. Cellular Network

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Educational Codeforces Round 5 E. Sum of Remainders 数学

    E. Sum of Remainders 题目连接: http://www.codeforces.com/contest/616/problem/E Description The only line ...

  9. Codeforces Educational Codeforces Round 5 D. Longest k-Good Segment 尺取法

    D. Longest k-Good Segment 题目连接: http://www.codeforces.com/contest/616/problem/D Description The arra ...

随机推荐

  1. Mybatis——helloWorld级程序

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC & ...

  2. slf4j(simple logging facade for java)

    http://www.tuicool.com/articles/IfeUfq   slf4j(simple logging facade for java)是Java的简单的日志门面,它 不是具体的日 ...

  3. php多进程实现

    php多进程实现 PHP有一组进程控制函数(编译时需要–enable-pcntl与posix扩展),使得php能在nginx系统中实现跟c一样的创建子进程.使用exec函数执行程序.处理信号等功能. ...

  4. EditText的一点深入的了解

    最近在开发android下的记事本程序时,频繁的使用EditText控件,折腾来折腾去,算是对其的了解更深入了一些.特将这些收获记录如下: 一.几个属性的介绍 android:gravity=&quo ...

  5. 用PHP实现验证码功能

    目前,不少网站为了防止用户利用机器人自动注册.登录.灌水,都采用了 验证码技术.所谓验证码,就是将一串随机产生的数字或符号,生成一幅图片, 图片里加上一些干扰象素(防止OCR),由用户肉眼识别其中的验 ...

  6. static方法与非static方法是否可以互相调用

    情况一.static方法调用非static方法 非静态方法只有实例对象才可调用,而静态方法随着类的加载而加载,类的加载在实例对象产生之前,所以静态方法不能调用非静态方法 情况二.非atic方法调用st ...

  7. Debian 安装 vmware-tools 手记

    debian 8.5 源 deb http://ftp.de.debian.org/debian jessie main http://mirrors.163.com/.help/debian.htm ...

  8. 记一次坑die(误)的题目--HDU2553--(DFS)

    ,N皇后问题   Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  9. Node.js学习 - Function

    Node.js函数和JavaScript类似 function say(word) { console.log(word); } function execute(someFunction, valu ...

  10. java邮件收发

    http://blog.csdn.net/ycg01/article/details/1394465 java邮件收发 标签: javaimportexceptionnulluserclass 200 ...