1486B.md (2250B)
1 Source: https://codeforces.com/problemset/problem/1486/B 2 3 B. Eastern Exhibition 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 You and your friends live in $n$ houses. Each house is located on a 2D plane, in a point with integer coordinates. There might be different houses located in the same point. The mayor of the city is asking you for places for the building of the Eastern exhibition. You have to find the number of places (points with integer coordinates), so that the summary distance from all the houses to the exhibition is minimal. The exhibition can be built in the same point as some house. The distance between two points $(x_1, y_1)$ and $(x_2, y_2)$ is $|x_1 - x_2| + |y_1 - y_2|$, where $|x|$ is the absolute value of $x$. 22 23 Input 24 25 First line contains a single integer $t$ $(1 \leq t \leq 1000)$ — the number of test cases. 26 27 The first line of each test case contains a single integer $n$ $(1 \leq n \leq 1000)$. Next $n$ lines describe the positions of the houses $(x_i, y_i)$ $(0 \leq x_i, y_i \leq 10^9)$. 28 29 It's guaranteed that the sum of all $n$ does not exceed $1000$. 30 31 Output 32 33 For each test case output a single integer - the number of different positions for the exhibition. The exhibition can be built in the same point as some house. 34 35 Example 36 37 Input 38 39 ``` 40 6 41 3 42 0 0 43 2 0 44 1 2 45 4 46 1 0 47 0 2 48 2 3 49 3 1 50 4 51 0 0 52 0 1 53 1 0 54 1 1 55 2 56 0 0 57 1 1 58 2 59 0 0 60 2 0 61 2 62 0 0 63 0 0 64 ``` 65 66 Output 67 68 ``` 69 1 70 4 71 4 72 4 73 3 74 1 75 ``` 76 77 Note 78 79 Here are the images for the example test cases. Blue dots stand for the houses, green — possible positions for the exhibition. 80 81  82 83 First test case. 84 85  86 87 Second test case.  88 89 Third test case.  90 91 Fourth test case.  92 93 Fifth test case.  94 95 Sixth test case. Here both houses are located at $(0, 0)$.