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的概 ...
随机推荐
- 浏览器缓存机制(HTTP缓存机制)
其机制是根据HTTP报文的缓存标识进行的. 过程:浏览器发起HTTP请求 – 服务器响应该请求.那么浏览器第一次向服务器发起该请求后拿到请求结果,会根据响应报文中HTTP头的缓存标识,决定是否缓存结果 ...
- Android 复制文本内容到系统剪贴板(自由复制)
直接上代码:(对应的类:android.content.ClipboardManager) //获取剪贴板管理器: ClipboardManager cm = (ClipboardManager) g ...
- 【Oracle】进入sqlplus 删除键backspace时出现^H
当oracle进入sqlplus后,输入命令时候出现错误,我们按平时的习惯使用backspace键删除错误信息,此时会出现^H 解决办法:进入sqlplus之前,使用stty erase '^H'命令 ...
- 三维重建:SLAM相关的一些术语解释
SLAM是一个工程问题,再次复习一下工程中可能用到的名词解释. 还是不要看了,高翔的科普读物已经出版了,读他的<slam十四讲>就可以了. 一.度量相关: 世界坐标系:描述图像的平面坐标系 ...
- Redis 之string结构及命令详解
1.set key value ex 秒数 px 毫秒数 nx / xx 设置一个值,注:ex 与 px 同时存在时,取写在后面的一个为有效期,nx表示key不存时设置成功,xx表示 ...
- MySQL在Linux下的表名如何不区分大小写
MySQL在Linux下的表名如何不区分大小写 今天测试的时候,遇到一些问题,明明看到数据,就是查不出来;后来发现,在linux下, mysql的表名区分大小写,而在windows下是不区分,从w ...
- webstorm前端开发工具vue环境配置及运行项目
1:webstorm的安装:2:node.js的安装3:安装Git4:vue-cli 安装前面两步就可以把项目启动了,安装Git主要是打开命令窗口,这样就可以用liunx命令了,原理跟cmd差不多 V ...
- nyoj4-ASCII码排序
ASCII码排序 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符. 输入 第一行输入一个数N, ...
- cxgrid的过滤%x%问题【备查】
把这个文件复制到你的程序目录\DevExpress VCL\ExpressDataController\Sources\cxLike.pas function LikeStr(const AStr, ...
- Java基础学习总结(39)——Log4j 1使用教程
1. 配置文件 Log4J配置文件的基本格式如下: #配置根Logger log4j.rootLogger = [ level ] , appenderName1 , appenderN ...