You are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n points, which area exceeds S.

Alyona tried to construct a triangle with integer coordinates, which contains all n points and which area doesn't exceed 4S, but, by obvious reason, had no success in that. Please help Alyona construct such triangle. Please note that vertices of resulting triangle are not necessarily chosen from n given points.

Input

In the first line of the input two integers n and S (3 ≤ n ≤ 5000, 1 ≤ S ≤ 1018) are given — the number of points given and the upper bound value of any triangle's area, formed by any three of given n points.

The next n lines describes given points: ith of them consists of two integers xi and yi ( - 108 ≤ xi, yi ≤ 108) — coordinates of ith point.

It is guaranteed that there is at least one triple of points not lying on the same line.

Output

Print the coordinates of three points — vertices of a triangle which contains all n points and which area doesn't exceed 4S.

Coordinates of every triangle's vertex should be printed on a separate line, every coordinate pair should be separated by a single space. Coordinates should be an integers not exceeding 109 by absolute value.

It is guaranteed that there is at least one desired triangle. If there is more than one answer, print any of them.

Example

Input
4 1
0 0
1 0
0 1
1 1
Output
-1 0
2 0
0 2

题意:给定N个点,保证最大三角形面积不超过S,现在让你找一个面积不超过4*S的三角形,使之覆盖所有点。

思路:找到最大三角形X,然后按照平行四边形的样子,对称出3个三角形。即可覆盖所有点,否则可以反证X的面积不是最大。

所以按照上一题一样,先求凸包,然后求最大三角形的坐标,然后对称。 如图:

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define RC rotating_calipers
using namespace std;
const int maxn=;
struct point{
ll x,y;
point(ll x=,ll y=):x(x),y(y){}
bool operator <(const point &c) const { return x<c.x||(x==c.x&&y<c.y);}
point operator -(const point &c)const { return point(x-c.x,y-c.y);}
};
ll det(point A,point B){ return A.x*B.y-A.y*B.x;}
ll det(point O,point A,point B){ return det(A-O,B-O);}
point a[maxn],ch[maxn],A,B,C;
void convexhull(int n,int &top)
{
sort(a+,a+n+); top=;
for(int i=;i<=n;i++){
while(top>&&det(ch[top-],ch[top],a[i])<=) top--;
ch[++top]=a[i];
}
int ttop=top;
for(int i=n-;i>=;i--){
while(top>ttop&&det(ch[top-],ch[top],a[i])<=) top--;
ch[++top]=a[i];
}
}
void rotating_calipers(point p[],int top)
{
ll ans=; int now;
rep(i,,top-){
int now=i+;
rep(j,i+,top-){
while(now<=top&&abs(det(p[i],p[j],p[now]))<abs(det(p[i],p[j],p[now+]))){
now++;
}
ll tmp=abs(det(p[i],p[j],p[now]));
if(tmp>ans) ans=tmp,A=p[i],B=p[j],C=p[now];
}
}
}
int main()
{
int N; ll S;
scanf("%d%I64d",&N,&S);
for(int i=;i<=N;i++) scanf("%I64d%I64d",&a[i].x,&a[i].y);
int top; convexhull(N,top);
RC(ch,top-);
printf("%I64d %I64d\n",A.x+B.x-C.x,A.y+B.y-C.y);
printf("%I64d %I64d\n",A.x+C.x-B.x,A.y+C.y-B.y);
printf("%I64d %I64d\n",B.x+C.x-A.x,B.y+C.y-A.y);
return ;
}

最新文章

  1. 把Tomcat注册为windows服务
  2. elastichq auto connect
  3. Oracle中INSTR、SUBSTR和NVL的用法
  4. lsof在运维中的应用
  5. [转]Caffe在Linux下的安装,编译,实验
  6. ASP.NET MVC 5 入门教程 (3) 路由route
  7. 解决BeanNotOfRequiredTypeException: Bean named &#39;XXX&#39; must be of type XXX, but was actually of type XXX问题
  8. python-twisted
  9. S5PV210裸板驱动:启动
  10. wiki-editor语法
  11. 正整数转换成N进制的数组
  12. 【基于spark IM 的二次开发笔记】第一天 各种配置
  13. Laravle Introduction
  14. RobotFramework+Selenium2library+Appium+Python+RIDE安装指南
  15. JavaWeb核心编程之(三.4)Servlet Context 配置
  16. C# 逆变与协变
  17. 自己动手写http服务器——主程序(三)
  18. Java分布式锁,搞懂分布式锁实现看这篇文章就对了
  19. Game Engine Architecture 7
  20. buffer IO和direct IO

热门文章

  1. Nginx -HTTP和反向代理服务器简单配置
  2. range基础
  3. Docker容器技术-命令进阶
  4. R的基础学习之数据结构
  5. php数组函数-array_rand()
  6. 【转载】关于C++中cin的几点说明性总结
  7. EF Code-First 学习之旅 继承策略
  8. lua闭包浅析及项目应用
  9. Linux嵌入式 -- 内核 - 系统调用
  10. Eclipse导出apk