第一反应是在凸包上随便找一条边,然后找剩下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. Sanatorium

    Sanatorium time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  2. eclipse提升注解提示速度

    preference--输入content--java--editor--content Assist--aoto delay 选项 改为100或者更低  提示速度              --ao ...

  3. iOS 静态库,动态库与 Framework 浅析

    静态库与动态库的区别 首先来看什么是库,库(Library)说白了就是一段编译好的二进制代码,加上头文件就可以供别人使用. 什么时候我们会用到库呢?一种情况是某些代码需要给别人使用,但是我们不希望别人 ...

  4. 灵感闪现 篇 (一) 2d场景 3d 效果

    中途打断一下 ,框架文档的 更新. 另开一篇主题为 灵感闪现的 板块. 在工作生活中,总有发现新事物或新东西 而让自己突然 灵感闪现的时候,那么这个时候,我必须要抓住,并尽快把 这份灵感实现下来. 之 ...

  5. jenkins插件 build-name-setter

    #${BUILD_NUMBER}-${PROJECT_NAME}-${ENV,var="VARIABLENAME"}-${ENV,var="BUILD_USER" ...

  6. Python基础学习1---函数

    Python函数篇 函数是重用的程序选, 他们允许给一块语句一个名称,然后可以在你的程序的任何地方是使用这个名称任意多次地运行这个语句块.这个就被称为 调用  函数.比如内建了很多高效的函数 如len ...

  7. jquery_api(事件一)

    一 .unload在火狐,谷歌无法弹出alerta是因为这两个浏览器默认组织alert弹出,unload事件可以进行一些对象销毁,事件解除绑定等清理工作. 如果你想在用户离开页面之前确认是否离开,最好 ...

  8. 使用PHP实现文件上传和多文件上传

    PHP 2013 年 9 月 4 日 暂无评论 在PHP程序开发中,文件上传是一个使用非常普遍的功能,也是PHP程序员的必备技能之一.值得高兴的是,在PHP中实现文件上传功能要比在Java.C#等语言 ...

  9. springMVC的拦截器工作流程

    首先,springmvc的拦截器配置在这就不多说了.主要讲一下拦截器的三个方法的执行顺序. preHandle方法一定是最先执行的方法,如果它返回为false下面的方法均不执行. postHandle ...

  10. mybatis generator Date类型时间丢失

    开篇 本次项目换用了Oracle数据库,讲真,真的不好用,不太喜欢,比较喜欢轻量级的MySQL但是不得不说从Oracle的严谨中学到不少好东西. <resultMap id="Base ...