A. Wilbur and Swimming Pool
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 test(s)
Input
2 0 0 1 1
Output
1
Input
1 1 1
Output
-1
Note

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.

题意 给你n个点 n<=4 保证是矩形的顶点  求矩形的面积

很水的一道题目 题意看懂 就可以

要不是我挂了综测 我是不会 贴的

作死排了个序 沙雕

#include<bits/stdc++.h>
using namespace std;
int n;
struct node
{
int x;
int y;
}N[5];
int main()
{
scanf("%d",&n);
memset(N,0,sizeof(N));
for(int i=0;i<n;i++)
scanf("%d%d",&N[i].x,&N[i].y);
if(n<2)
{
printf("-1\n");
return 0;
}
if(n==2)
{
if(N[0].x!=N[1].x&&N[0].y!=N[1].y)
printf("%d\n",abs((N[1].x-N[0].x)*(N[1].y-N[0].y)));
else
printf("-1\n");
return 0;
}
for(int i=1;i<n;i++)
{
if(N[0].x!=N[i].x&&N[0].y!=N[i].y)
{
printf("%d\n",abs((N[i].x-N[0].x)*(N[i].y-N[0].y)));
return 0;
}
}
for(int i=0;i<n;i++)
{
if(N[1].x!=N[i].x&&N[1].y!=N[i].y)
{
printf("%d\n",abs((N[i].x-N[1].x)*(N[i].y-N[1].y)));
return 0;
}
}
return 0;
}

Codeforces Round #331 (Div. 2) A的更多相关文章

  1. Codeforces Round #331 (Div. 2) E. Wilbur and Strings dfs乱搞

    E. Wilbur and Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596 ...

  2. Codeforces Round #331 (Div. 2) D. Wilbur and Trees 记忆化搜索

    D. Wilbur and Trees Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/p ...

  3. Codeforces Round #331 (Div. 2)C. Wilbur and Points 贪心

    C. Wilbur and Points Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/ ...

  4. Codeforces Round #331 (Div. 2) B. Wilbur and Array 水题

    B. Wilbur and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/p ...

  5. Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool 水题

    A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

  6. Codeforces Round #331 (Div. 2)【未完待续】

    http://codeforces.com/problemset/problem/596/B GGGGGGGGGGGGGGGGGGG

  7. Codeforces Round #331 (Div. 2)

    水 A - Wilbur and Swimming Pool 自从打完北京区域赛,对矩形有种莫名的恐惧.. #include <bits/stdc++.h> using namespace ...

  8. Codeforces Round #331 (Div. 2) C. Wilbur and Points

    C. Wilbur and Points time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  9. Codeforces Round #331 (Div. 2) _A. Wilbur and Swimming Pool

    A. Wilbur and Swimming Pool time limit per test 1 second memory limit per test 256 megabytes input s ...

  10. Codeforces Round #331 (Div. 2) B. Wilbur and Array

    B. Wilbur and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. Java开发工程师(Web方向) - 04.Spring框架 - 第3章.AOP技术

    第3章--AOP技术 Spring框架 - AOP概述 笔记https://my.oschina.net/hava/blog/758873Spring框架 - AOP使用 笔记https://my.o ...

  2. 【WXS数据类型】Array

    属性: 名称 值类型 说明 [Array].constructor [String] 返回值为“Array”,表示类型的结构字符串 [Array].length [Number] 返回数组长度 方法: ...

  3. 代码对齐 (Alignment of Code,ACM/ICPC NEERC 2010,UVa1593)

    题目描述: 解题思路: 输入时提出单个字符串,并用一个数组记录每列最长长度,格式化输出 #include <iostream> #include <algorithm> #in ...

  4. mvc中actionresult的返回值类型

    以前一直没注意actionresult都能返回哪些类型的类型值(一直用的公司的内部工具类初始化进行返回的),今天跟大家分享一下(也是转载的别人的日志qaq). 首先我们了解一下对action的要求: ...

  5. VBS简明教程

    VBS简明教程   一.输出 VBS的输出使用函数Msgbox调用对话框进行输出. Msgbox(message) Message为要输出的信息 二.输入 VBS的输入,调用函数Inputbox()进 ...

  6. quartz入门实例

    一 Quarta介绍 1 Quartz是什么 Quartz就是一个纯 Java 实现的作业调度工具,相当于数据库中的 Job.Windows 的计划任务.Unix/Linux 下的 Cron,但 Qu ...

  7. HADOOP docker(七):hive权限管理

    1. hive权限简介1.1 hive中的用户与组1.2 使用场景1.3 权限模型1.3 hive的超级用户2. 授权管理2.1 开启权限管理2.2 实现超级用户2.3 实现hiveserver2用户 ...

  8. C Program基础-宏定义

    写好c语言,漂亮的宏定义是非常重要的,我们在阅读别人工程时,往往能看到大量的宏定义,宏定义可以增加代码的可读性,也能增加代码的可移植性,一个好的宏定义甚至是一件艺术品.今天我们就来看看宏定义的方方面面 ...

  9. nginx虚拟目录实现两个后台使用

    购买了阿里云机器,准备搭建一套备份的后台,由于资源有限所以将两个后台搭建到一组SLB下的两台WEB上. 使用软件:NGINX+PHP root@xx conf.d]# yum install php- ...

  10. iconFont 阿里巴巴矢量图标使用方法

    挑选图标的过程(共6步) 进入网站:Iconfont网址:http://www.iconfont.cn 点击网站上方的“官方图标库”,选择自己喜欢的图标.在这里我选择天猫的图标库. 选择好自己喜欢的图 ...