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

Note

要找个三角形把所有点都包在里面

画画图就会发现,只要在这些点中找个面积最大的三角形,然后对三条边都翻折过去变成一个4倍大的三角形就好了

面积最大的三角形找法有点迷……一开始就选123号点,然后每次尝试把一个点替换之后面积会不会变大

一直做到不再变大为止。

这玩意似乎有什么定理 可以证明2-stable point一定属于3-stable point?

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void write(LL a)
{
if (a<){printf("-");a=-a;}
if (a>=)write(a/);
putchar(a%+'');
}
inline void writeln(LL a){write(a);printf("\n");}
LL n,k;
struct point{
LL x,y;
}p[];
int a,b,c;
point operator +(point a,point b){return (point){a.x+b.x,a.y+b.y};}
point operator -(point a,point b){return (point){a.x-b.x,a.y-b.y};}
inline LL calc(int a,int b,int c)
{
LL x1=p[c].x-p[a].x,y1=p[c].y-p[a].y,x2=p[b].x-p[a].x,y2=p[b].y-p[a].y;
LL ans=x1*y2-x2*y1;
if (ans<)ans=-ans;
return ans;
}
int main()
{
n=read();k=read();
for (int i=;i<=n;i++)p[i].x=read(),p[i].y=read();
a=;b=;c=;
bool refresh=;
while (!refresh)
{
refresh=;
for (int i=;i<=n;i++)
if (i!=a&&i!=b&&i!=c)
{
if (calc(a,b,c)<calc(i,b,c))a=i,refresh=;
else if (calc(a,b,c)<calc(a,i,c))b=i,refresh=;
else if (calc(a,b,c)<calc(a,b,i))c=i,refresh=;
}
}
point d=p[a]+p[b]-p[c],e=p[a]+p[c]-p[b],f=p[c]+p[b]-p[a];
printf("%lld %lld\n",d.x,d.y);
printf("%lld %lld\n",e.x,e.y);
printf("%lld %lld\n",f.x,f.y);
}

cf 682E

cf682E Alyona and Triangles的更多相关文章

  1. CodeForces 682E Alyona and Triangles (计算几何)

    Alyona and Triangles 题目连接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/J Description You ar ...

  2. Codeforces Round #358 (Div. 2) E. Alyona and Triangles 随机化

    E. Alyona and Triangles 题目连接: http://codeforces.com/contest/682/problem/E Description You are given ...

  3. CodeForces - 682E: Alyona and Triangles(旋转卡壳求最大三角形)

    You are given n points with integer coordinates on the plane. Points are given in a way such that th ...

  4. Count the number of possible triangles

    From: http://www.geeksforgeeks.org/find-number-of-triangles-possible/ Given an unsorted array of pos ...

  5. Codeforces Round #381 (Div. 2)D. Alyona and a tree(树+二分+dfs)

    D. Alyona and a tree Problem Description: Alyona has a tree with n vertices. The root of the tree is ...

  6. Codeforces Round #381 (Div. 2)C. Alyona and mex(思维)

    C. Alyona and mex Problem Description: Alyona's mother wants to present an array of n non-negative i ...

  7. Codeforces Round #381 (Div. 2)B. Alyona and flowers(水题)

    B. Alyona and flowers Problem Description: Let's define a subarray as a segment of consecutive flowe ...

  8. Codeforces Round #381 (Div. 2)A. Alyona and copybooks(dfs)

    A. Alyona and copybooks Problem Description: Little girl Alyona is in a shop to buy some copybooks f ...

  9. Codeforces 740C. Alyona and mex 思路模拟

    C. Alyona and mex time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...

随机推荐

  1. 洛谷 P1330 封锁阳光大学

    题目描述 曹是一只爱刷街的老曹,暑假期间,他每天都欢快地在阳光大学的校园里刷街.河蟹看到欢快的曹,感到不爽.河蟹决定封锁阳光大学,不让曹刷街. 阳光大学的校园是一张由N个点构成的无向图,N个点之间由M ...

  2. (十)mybatis之配置(mybatis-config.xml)

    配置  可以从前篇的文章中知道(https://www.cnblogs.com/NYfor2018/p/9093472.html ),要使用mybatis需要以下配置: 1.  mybatis-con ...

  3. (七)maven之阿里云镜像提高jar下载速度

    阿里云国内镜像,提高jar包下载速度 镜像 maven默认会从中央仓库下载包,但是下载过几次就知道,下载速度非常慢.镜像就相当于是中央仓库的一个副本,内容和中央仓库完全一样,而且同时也能保证下载速度, ...

  4. MVC视图特性

    在主界面的视图中可以使用viewdata,引用主界面的分布视图界面也可以调用主界面的分部视图,但是分部视图不可以定义viewdata并使用 例子如下: // // GET: /Home/ public ...

  5. 如何修改IOS的默认字体

    The first is workaround wich is iterating over all the labels in your UIView and change the labels f ...

  6. 操作系统项目:向Linux内核添加一个系统调用

    内容: 向Linux增加一个系统调用 撰写一个应用测试程序调用该系统调用 使用ptrace或类似的工具对该测试程序进行跟踪调 环境: 1.vmware workstation 15.0.0 2.ubu ...

  7. Shift-Invariant论文笔记

    ICML 2019 Making Convolutional Networks Shift-Invariant Again ICML 2019 Making Convolutional Network ...

  8. python之常见的坑

    li = [1,2,3,4] # [1,3,4] # 索引值是奇数的删除 for i in range(4): if i % 2 == 1: li.pop(i) # 会报错 print(li) 面试题 ...

  9. |chromosomal walk |zoo blot|鉴定疾病gene|

    5.6基于外显子的保守性鉴定真核生物编码蛋白质的基因 鉴定功能性基因的流程是:1.连锁分析找到该基因的染色体的特定区域:2.在这段序列中选择一条短序列,寻找满足两个条件的基因(条件一:因为功能性基因是 ...

  10. tomcat性能优化 - 网络抄录

    tomcat默认参数是为开发环境制定,而非适合生产环境,尤其是内存和线程的配置,默认都很低,容易成为性能瓶颈. tomcat内存优化 linux修改TOMCAT_HOME/bin/catalina.s ...