A. Wilbur and Swimming Pool
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the area of the rectangle must be positive. Wilbur had all four vertices of the planned pool written on a paper, until his friend came along and erased some of the vertices.

Now Wilbur is wondering, if the remaining n vertices of the initial rectangle give enough information to restore the area of the planned swimming pool.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 4) — the number of vertices that were not erased by Wilbur's friend.

Each of the following n lines contains two integers xi and yi ( - 1000 ≤ xi, yi ≤ 1000) —the coordinates of the i-th vertex that remains. Vertices are given in an arbitrary order.

It's guaranteed that these points are distinct vertices of some rectangle, that has positive area and which sides are parallel to the coordinate axes.

Output

Print the area of the initial rectangle if it could be uniquely determined by the points remaining. Otherwise, print  - 1.

Sample test(s)
Input
2 0 0 1 1
Output
1
Input
1 1 1
Output
-1
Note

In the first sample, two opposite corners of the initial rectangle are given, and that gives enough information to say that the rectangle is actually a unit square.

In the second sample there is only one vertex left and this is definitely not enough to uniquely define the area.

题意 给你n个点 n<=4 保证是矩形的顶点  求矩形的面积

很水的一道题目 题意看懂 就可以

要不是我挂了综测 我是不会 贴的

作死排了个序 沙雕

#include<bits/stdc++.h>
using namespace std;
int n;
struct node
{
int x;
int y;
}N[5];
int main()
{
scanf("%d",&n);
memset(N,0,sizeof(N));
for(int i=0;i<n;i++)
scanf("%d%d",&N[i].x,&N[i].y);
if(n<2)
{
printf("-1\n");
return 0;
}
if(n==2)
{
if(N[0].x!=N[1].x&&N[0].y!=N[1].y)
printf("%d\n",abs((N[1].x-N[0].x)*(N[1].y-N[0].y)));
else
printf("-1\n");
return 0;
}
for(int i=1;i<n;i++)
{
if(N[0].x!=N[i].x&&N[0].y!=N[i].y)
{
printf("%d\n",abs((N[i].x-N[0].x)*(N[i].y-N[0].y)));
return 0;
}
}
for(int i=0;i<n;i++)
{
if(N[1].x!=N[i].x&&N[1].y!=N[i].y)
{
printf("%d\n",abs((N[i].x-N[1].x)*(N[i].y-N[1].y)));
return 0;
}
}
return 0;
}

Codeforces Round #331 (Div. 2) A的更多相关文章

  1. Codeforces Round #331 (Div. 2) E. Wilbur and Strings dfs乱搞

    E. Wilbur and Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596 ...

  2. Codeforces Round #331 (Div. 2) D. Wilbur and Trees 记忆化搜索

    D. Wilbur and Trees Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/p ...

  3. Codeforces Round #331 (Div. 2)C. Wilbur and Points 贪心

    C. Wilbur and Points Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/ ...

  4. Codeforces Round #331 (Div. 2) B. Wilbur and Array 水题

    B. Wilbur and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/p ...

  5. Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool 水题

    A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

  6. Codeforces Round #331 (Div. 2)【未完待续】

    http://codeforces.com/problemset/problem/596/B GGGGGGGGGGGGGGGGGGG

  7. Codeforces Round #331 (Div. 2)

    水 A - Wilbur and Swimming Pool 自从打完北京区域赛,对矩形有种莫名的恐惧.. #include <bits/stdc++.h> using namespace ...

  8. Codeforces Round #331 (Div. 2) C. Wilbur and Points

    C. Wilbur and Points time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  9. Codeforces Round #331 (Div. 2) _A. Wilbur and Swimming Pool

    A. Wilbur and Swimming Pool time limit per test 1 second memory limit per test 256 megabytes input s ...

  10. Codeforces Round #331 (Div. 2) B. Wilbur and Array

    B. Wilbur and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. (原) MaterialEditor部- UmateriaEditor中 Node编译过程和使用(1)

    @author: 白袍小道 转载说明原处 插件同步在GITHUB: DaoZhang_XDZ     最后YY需求(手滑) 1.在理清楚基础套路和细节后,自定义纹理资源,并加入到现有UE材质系统 2. ...

  2. 【20180807模拟测试】tree

    题目描述 或许会传送失败的传送门 #分析 考虑如何才能让白边显得更(不)重要,即在每条白边上(加上)减去一个值. 我们可以二分这个值,然后用寻常方法做最小生成树.统计在此最小生成树里有多少白 边. 然 ...

  3. cenos环境变量配置

    Beego环境搭建和bee工具安装使用,以Windows环境为例. 首先,下载并安装好GO并配置好GOROOT和GOPATH环境变量(如果您是用msi包安装的go,那么这些环境变量已经设置好了).并在 ...

  4. 创建https证书

    第一个里程碑:创建https证书 创建文件认证目录 mkdir /application/nginx/key/ -p 在认证目录下创建认证文件 openssl req -new -x509 -node ...

  5. JSP传递数组给JS的方法

    由于JSP页面的数组无法直接传到JS.所以采用以下方法来获取数组. <% String[] title = { "姓名 ", "学号 ", "性 ...

  6. jquery delayLoading.js插件的延迟加载效果和图片延迟加载

    1.首页给大家介绍一下这款插件的主要用途 主要应用于图片的延迟加载,而且可以变换不同的延迟加载效果,适合相册图片.有做相册的可以考虑应用. 2.兼容IE7以上都兼容,其他的浏览器也兼容.所以说兼容性还 ...

  7. 移动端的picker参考vux

    参考vux移动端的ui组件,做了一个picker,测试在微信,uc主流浏览器能够正常工作.而在华为浏览器根本不能使用.而测试了vux的原有picker组件,发现在华为自带浏览器中,效果依然能够实现. ...

  8. 这些JavaScript编程黑科技,装逼指南,高逼格代码,让你惊叹不已

    Javascript是一门很吊的语言,我可能学了假的JavaScript,哈哈,大家还有什么推荐的,补充送那啥邀请码. 本文秉承着:你看不懂是你SB,我写的代码就要牛逼. 1.单行写一个评级组件 &q ...

  9. docker使用记录

    1.安装(开始前要注意系统内核版本是否合适,建议用7以上的系统吧,少点坑) //安装docker yum -y install docker-io //启动 service docker start ...

  10. 第54天:原生js实现轮播图效果

    一.轮播图的原理: 一系列的大小相等的图片平铺,利用CSS布局只显示一张图片,其余隐藏.通过计算偏移量利用定时器实现自动播放,或通过手动点击事件切换图片. 二.Html布局 首先父容器containe ...