CodeForces 596A
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
2
0 0
1 1
1
1
1 1
-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的更多相关文章
- 【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 ...
- CodeForces 596A Wilbur and Swimming Pool
水题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> u ...
- HPU周赛题目解析
A - Wilbur and Swimming Pool Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- Codeforces--596A--Wilbur and Swimming Pool(数学)
A - Wilbur and Swimming Pool Crawling in process... Crawling failed Time Limit:1000MS Memory ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
随机推荐
- EntityFramewok 插入Mysql数据库 中文产生乱码解决
首先Mysql表,建表的时候,有没有选择UTF8,如果是默认的编码latin1,就会产生乱码 这里修改后,还是乱码,那就要检查发生乱码的列是不是UTF8格式 然后修改App.Config或者Web.C ...
- java基础学习四
一.java中的基本数据类型 二.double和float精度不准的问题 double和float本身确实存在某种缺陷,不能用于精确计算. 解决办法: 用java.math.BigDecimal,通过 ...
- Java_Web之神奇的Ajax
为什么使用Ajax? 无刷新:不刷新整个页面,只刷新局部 无刷新的好处 提供类似C/S的交互效果,操作更方面 只更新部分页面,有效利用带宽 什么是Ajax? XMLHttpRequest常用方 ...
- C#面对“重载”的Win 32 函数
在Win32 Api中有很多添加/设置函数在参数上支持多种不同类型的结构体.这些参数定义为LPVOID* 或者LPBYTE,LPVOID*一般由Win32 分配内存空间,在C#从通过System.In ...
- swift 类型系统 Self self Type
namedClass:静态类型:与类型实现直接关联:可以用于初始化.类型检查等. namedClass.self:@thick,脱敏(脱关)类型:动态类型:可以作为元类型的实例:可以作为类型参量进行传 ...
- jq 跨域请求
//使用getJSON <script type="text/javascript"> $(function () { $("#btn2").cli ...
- cocos ios Label组件问题
软件:cocos creator v1.9.0 开发的过程中,一直在web上预览,Label组件显示一直没问题.在打包到ios上时,出现问题了: Label组件: 当我们缩小字体,发现没问题了,当我们 ...
- javeee 字节Buffered
package Zy; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io. ...
- Python基础知识-Day4
一.函数关键字关键字是Python内置的,具有特殊意义的标识符,自定义标识符命名时不可与之重复.可以通过以下代码查看Python内置的关键字内容. import keyword print(keywo ...
- vmware Horizon 7 与远程桌面(mstsc)兼容性问题解决办法
关于Horizon 7 Agent与远程桌面(mstsc)兼容性问题解决办法 在Horizon 7环境中,在桌面模板安装了Horizon Agent后,就无法直接通过微软的远程桌面(mstsc)工具连 ...