日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2025/6/17 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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/contest/596/problem/A

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

Sample Output

1

HINT

?

題意

一個矩形,4個點,但是被人擦去了,現在就只有n個點了

然后問你這n個點能不能構成獨一無二的矩形,如果可以輸出面積

否則否則輸出-1

題解:

掃一遍四個點,判斷minx==maxx miny==maxy,滿足兩個中的一個,就輸出-1

否則輸出面積就好了

代碼

#include<iostream> #include<stdio.h> #include<algorithm> using namespace std;int main() {int n;cin>>n;int minx,maxx,miny,maxy;cin>>minx>>miny;maxx=minx,maxy=miny;if(n==1)return puts("-1");for(int i=1;i<n;i++){int x,y;cin>>x>>y;minx=min(minx,x);maxx=max(maxx,x);miny=min(miny,y);maxy=max(maxy,y);}if((maxx==minx)||(maxy==miny))return puts("-1");printf("%d\n",(maxx-minx)*(maxy-miny)); }

?

轉載于:https://www.cnblogs.com/qscqesze/p/4967947.html

總結

以上是生活随笔為你收集整理的Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool 水题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。