CF596A.Wilbur and Swimming Pool

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

在向游泳池中做了几次糟糕的跳水后,威尔伯想在自家后院建造一个矩形形状的游泳池。他已建立了坐标系,并希望该矩形的各边与坐标轴平行。当然,该矩形的面积必须为正。威尔伯原本将计划中游泳池的四个顶点全部写在了一张纸上,但他的朋友随后擦掉了一些顶点。

现在威尔伯想知道:若初始矩形剩余的 nn 个顶点所提供的信息,是否足以恢复计划中游泳池的面积。

输入格式

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 x__i and y__i ( - 1000 ≤ x__i, y__i ≤ 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.

输入的第一行包含一个整数 nn(1 ≤ n ≤ 41 ≤ n ≤ 4)—— 表示未被 Wilbur 的朋友擦除的顶点个数。

接下来的 nn 行,每行包含两个整数 xix_i 和 yiy_i(−1000 ≤ xi, yi ≤ 1000-1000 ≤ x_i, y_i ≤ 1000)—— 表示第 ii 个剩余顶点的坐标。顶点以任意顺序给出。

保证这些点是某个面积为正、且边与坐标轴平行的矩形的互异顶点。

输出格式

Print the area of the initial rectangle if it could be uniquely determined by the points remaining. Otherwise, print  - 1.

如果根据剩余的点可以唯一确定初始矩形的面积,则输出该面积;否则输出 -1。

输入输出样例

  • 输入#1

    2
    0 0
    1 1

    输出#1

    1
  • 输入#2

    1
    1 1

    输出#2

    -1

说明/提示

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.

在第一个样例中,给出了初始矩形的两个对角顶点,这足以说明该矩形实际上是一个单位正方形。

在第二个样例中,仅剩一个顶点,这显然不足以唯一确定面积。

输入解题思路,AI测评打分。不知道怎么写?

首页