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的概 ...
随机推荐
- 生成jsp验证码的代码详解(servlet版)
package util; import java.util.*; import java.io.*; import java.awt.*; import java.awt.image.*; impo ...
- MySql-Connector for NET 连接驱动选择
尝试在Visual Studio2010, 2012环境下链接Mysql, 为啥不直接在App.config里面写字符串, 当然是可以,但是当你想用EF 的时候,必须要有个数据源, 首先在[服务资源管 ...
- 省市区县的sql语句——城市
/*SQLyog v10.2 MySQL - 5.5.48 : Database - 省市县****************************************************** ...
- redis-linux
redis3.0.4 server版本 jedis-2.7.2.jar spring-data-redis-1.6.0.RELEASE.jar commons-pool2-2.3.jar spring ...
- 获取 PHPstorm编辑器 注册码地址
网址: http://idea.lanyus.com/ 注册码有效期为2016年11月24日至2017年11月23日使用前请将“0.0.0.0 account.jetbrains.com”添加到hos ...
- Android:JAVA使用HDF5存储
Hierarchical Data Format,可以存储不同类型的图像和数码数据的文件格式,并且可以在不同类型的机器上传输,同时还有统一处理这种文件格式的函数库.大多数普通计算机都支持这种文件格式. ...
- c++ 枚举与字符串 比较
读取字符串,然后将这个字符转换为对应的枚举. 如:从屏幕上输入'a',则转换为set枚举中对应的a,源代码如下: //关键函数为char2enum(str,temp); #include using ...
- PS CC2018 命令大全
1.图像: 设置图像大小:图像->图像大小->设置宽高 约束比例: 解除约束比例: 2.设置大小像素图片不模糊: 双击当前图层->新建图层样式->输入名称->确定-> ...
- eas之设置编辑界面分录的某一列不可编辑
KDTEntrys.getColumn(“xx”).getStayAttributes().setlokced(true);
- greenplum数据迁移
源集群: 登录集群su - gpadminpsql -d postgres查询数据库信息\l查询用户信息\du 备份需要迁移的库到指定目录pg_dump -C testdata > /home/ ...