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. 【springmvc+mybatis项目实战】杰信商贸-5.生产厂家DAO+SERVICE+CONTROLLER+JSP+配置文件

    上一篇我们创建了工程和一个Factory的po对象(javaBean),我们也写好了Mapper的映射文件,接下来我们来完成生产厂家的DAO与SERVICE,以及CONTROLLER,还有做显示的JS ...

  2. pymsql报错:UnicodeEncodeError: 'latin-1' codec can't encode characters End,OK!!

    UnicodeEncodeError: 'latin-1' codec can't encode characters的做法基本一致,后来发现是因为使用的是mysqldb,照着网上的方法修改配置应该可 ...

  3. appium关键字:

    ## Appium 服务关键字 <expand_table> |关键字|描述|实例||----|-----------|-------||`automationName`|你想使用的自动化 ...

  4. 关于mysql开元数据库的几个随想

    现在已经是凌晨了,昨天晚上写了我人生中的第一篇笔记,觉得没什么可写的,写了一个多小时都没写出什么,现在突然想写点东西了,这是一个比较有趣的问题,前两个月换了新工作,记得当初面试这份工作的时候面试到第三 ...

  5. ElasticSearch 2.0以后的改动导致旧的资料和书籍需要订正的部分

    id原先是可以通过path指定字段的 "thread": { "_id" : { "path" : "thread_id" ...

  6. 我的Vscode配置

    "editor.fontSize": 17,//字体大小 "editor.wordWrap": "on",//软换行 "files ...

  7. Spark Streaming - DStream

    1 Overview Spark Streaming is an extension of the core Spark API that enables scalable, high-through ...

  8. c#事件实质

    c#的事件实际上是对windows消息的封装: windows消息系统分为3部分:消息队列,消息循环,窗口过程(wndproc函数)

  9. Uva 1600 Patrol Robot (BFS 最短路)

    这道题运用的知识点是求最短路的算法.一种方法是利用BFS来求最短路. 需要注意的是,我们要用一个三维数组来表示此状态是否访问过,而不是三维数组.因为相同的坐标可以通过不同的穿墙方式到达. #inclu ...

  10. 第一次课堂作业---circle

    链接:circle