Description

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 Input

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

Hint

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.

一道签到题,然而我却wa了很多次,我一直以为是让我判断长方形,发现还要输出面积。。。。

 #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
int x,y;
}a[];
int main()
{
int n,i,j;
cin>>n;
for(i=;i<=n;i++)
cin>>a[i].x>>a[i].y;
if(n==)
{
cout<<"-1"<<endl;
}
else if(n==)
{
if(a[].x==a[].x||a[].y==a[].y)
{
cout<<"-1"<<endl;
}
else
cout<<abs(a[].x-a[].x)*abs(a[].y-a[].y)<<endl;
}
else
{
for(i=;i<=n;i++)
{
for(j=;j<=n;j++)
{
if(a[i].x!=a[j].x&&a[i].y!=a[j].y)
{
cout<<abs(a[i].x-a[j].x)*abs(a[i].y-a[j].y)<<endl;
return ;
}
}
}
cout<<"-1"<<endl;
}
return ;
}

CodeForces 596A的更多相关文章

  1. 【CodeForces 596A】E - 特别水的题5-Wilbur and Swimming Pool

    Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the ...

  2. CodeForces 596A Wilbur and Swimming Pool

    水题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> u ...

  3. HPU周赛题目解析

    A - Wilbur and Swimming Pool Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  4. Codeforces--596A--Wilbur and Swimming Pool(数学)

     A - Wilbur and Swimming Pool Crawling in process... Crawling failed Time Limit:1000MS     Memory ...

  5. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  6. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  7. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  8. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  9. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

随机推荐

  1. python--8、socket网络编程

    socket socket可以完成C/S架构软件的开发.须知一个完整的计算机系统是由硬件.操作系统.应用软件三者组成,具备了这三个条件,一台计算机就可以工作了.但是要跟别人一起玩,就要上互联网(互联网 ...

  2. Unity引擎GUI之Canvas和EventSystem

    最近想写一套关于UGUI所有控件的基础使用教程系列,主要是根据本人的使用心得以及部分测试附带字面翻译来写的,所以其中可能难以避免会有不正确的地方. 好了进入主题,既然是第一篇,我觉得我有必要先介绍一下 ...

  3. 向properties文件中写入信息(针对获取properties文件失败的总结)

    前段时间项目需要将某个属性动态的写入项目发布路径下的properties文件中;但是实际发布时发现找不到maven项目resource路径下的project.properties文件,调试多次代码如下 ...

  4. C# 获取所有网卡信息

    private void Form1_Load(object sender, EventArgs e) { //获取说有网卡信息 NetworkInterface[] nics = NetworkIn ...

  5. (转)Bootstrap 之 Metronic 模板的学习之路 - (4)源码分析之脚本部分

    https://segmentfault.com/a/1190000006709967 上篇我们将 body 标签主体部分进行了简单总览,下面看看最后的脚本部门. 页面结尾部分(Javascripts ...

  6. java操作Excel的poi 设置单元格的对其方式

    设置单元格的对其方式 package com.java.poi; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.po ...

  7. JavaEE的起步

    因为某些原因,现在要从.net开发转向J2EE了,在这里记录一下学习经历

  8. Java设计模式之JDK动态代理原理

    动态代理核心源码实现public Object getProxy() { //jdk 动态代理的使用方式 return Proxy.newProxyInstance( this.getClass(). ...

  9. 单调队列 && 单调栈

    单调队列 && 单调栈 单调队列 维护某个滑动区间的min or max,可用于dp的优化 以维护min为例,采用STL双端队列实现 每次加入元素x前 先检查队首元素==滑动后要删除的 ...

  10. PAT_A1116#Come on! Let's C

    Source: PAT A1116 Come on! Let's C (20 分) Description: "Let's C" is a popular and fun prog ...