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的概 ...
随机推荐
- div自动适应浏览器窗口水平和垂直居中
html <body> <div id="centerDiv">自动适应水平和垂直居中</div> </body> css ;;} ...
- css2.0文档查阅及字体样式
css2.0文档查阅下载 网址:http://soft.hao123.com/soft/appid/9517.html <html xmlns="http://www.w3.o ...
- checked、disabled在原生、jquery、vue下不同写法
以下是原生和jquery <!DOCTYPE html> <html> <head> <meta http-equiv="Content ...
- Android常见错误整理
1.当我new class的时候,提示以下错误: Unable to parse template "Class" Error message: This template did ...
- Spring JPA 简单配置使用
JPA 常用配置: # JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration) spring.data.jpa.repositories.b ...
- android 国际化 横屏(land) 竖屏(port)margin外边距和padding内边距
android 国际化 横屏(land) 竖屏(port) 边距又分为内边距和外边距,即margin和padding.
- H265
H265 h265 一.名词 CTU: 编码树单元 CU: 编码单元 PU: 以CU为根,对CU进行划分,一个预测单元PU包含一个亮度预测块PB和两个色度预测块PB. TU: 以CU为根,变换单元T ...
- 45.4.7 序列:USER_SEQUENCES(SEQ)
45.4.7 序列:USER_SEQUENCES(SEQ) 要显示序列的属性,可以查询USER_SEQUENCES 数据字典视图.该视图也能用公有同义词SEQ 进行查询.USER_SEQUENCES ...
- dubbo之只订阅及只注册
只订阅 问题 如果有两个镜像环境,两个注册中心,有一个服务只在其中一个注册中心有部署,另一个注册中心还没来得及部署,而两个注册中心的其它应用都需要依赖此服务,所以需要将服务同时注册到两个注册中心,但却 ...
- 测试 Zoundry Raven
安装很方便,看看发布的内容是否好用 但发现从博客上取下来的内容是有问题的,不能正常打开