596A.md (1826B)
1 Source: https://codeforces.com/problemset/problem/596/A 2 3 A. Wilbur and Swimming Pool 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23 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. 24 25 Input 26 27 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. 28 29 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. 30 31 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. 32 33 Output 34 35 Print the area of the initial rectangle if it could be uniquely determined by the points remaining. Otherwise, print - 1. 36 37 Examples 38 39 Input 40 41 ``` 42 2 43 0 0 44 1 1 45 ``` 46 47 Output 48 49 ``` 50 1 51 ``` 52 53 Input 54 55 ``` 56 1 57 1 1 58 ``` 59 60 Output 61 62 ``` 63 -1 64 ``` 65 66 Note 67 68 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. 69 70 In the second sample there is only one vertex left and this is definitely not enough to uniquely define the area.