当前位置:网站首页>B. Eastern Exhibition- Codeforces Round #703 (Div. 2)
B. Eastern Exhibition- Codeforces Round #703 (Div. 2)
2022-07-24 03:13:00 【Qin xiaobaa】
B. Eastern Exhibition
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
You and your friends live in nn 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 (x1,y1)(x1,y1) and (x2,y2)(x2,y2) is |x1−x2|+|y1−y2||x1−x2|+|y1−y2|, where |x||x| is the absolute value of xx.
Input
First line contains a single integer tt (1≤t≤1000)(1≤t≤1000) — the number of test cases.
The first line of each test case contains a single integer nn (1≤n≤1000)(1≤n≤1000). Next nn lines describe the positions of the houses (xi,yi)(xi,yi) (0≤xi,yi≤109)(0≤xi,yi≤109).
It's guaranteed that the sum of all nn does not exceed 10001000.
Output
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.
Example
input
Copy
6 3 0 0 2 0 1 2 4 1 0 0 2 2 3 3 1 4 0 0 0 1 1 0 1 1 2 0 0 1 1 2 0 0 2 0 2 0 0 0 0
output
Copy
1 4 4 4 3 1
Note
Here are the images for the example test cases. Blue dots stand for the houses, green — possible positions for the exhibition.
First test case.
Second test case.
Third test case.
Fourth test case.
Fifth test case.
Sixth test case. Here both houses are located at (0,0)(0,0).
about X,Y The choice of the two does not affect each other , Manhattan is just XY The sum of the differences , So just let X,Y Take the minimum respectively , It turns into a one-dimensional problem , On a line segment , The smallest point of the sum of odd points Manhattan distance is at its midpoint , The minimum sum of Manhattan distances of even points is within the closed interval formed by the middle two points .
# include<iostream>
# include<complex.h>
# include<string.h>
# include<cstring>
# include<vector>
# include<algorithm>
# include<iomanip>
using namespace std;
typedef complex<double>cp;
# define mod 9999991
typedef long long int ll;
ll x[1010],y[1010];
int main ()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>x[i];
cin>>y[i];
}
if(n&1)
{
cout<<1<<'\n';
continue;
}
sort(x+1,x+1+n);
sort(y+1,y+1+n);
ll L,R;
L=x[n/2+1]-x[n/2]+1;
R=y[n/2+1]-y[n/2]+1;
cout<<L*R<<'\n';
}
return 0;
}
边栏推荐
- 日常杂谈(一)
- Ugui source code analysis - Mask
- TCP data transmission and performance
- JS 數組 isAarray() typeof
- Redux Usage Summary
- Unity Message push
- The function of SIP account - tell you what is SIP line
- SolidWorks CAM data cannot be recovered because a processed part has been detected.
- Ugui source code analysis - imaterialmodifier
- Ugui source code analysis - iclippable
猜你喜欢

CMT 注册——Google Scholar Id,Semantic Scholar Id,和 DBLP Id

Basic knowledge of trigger (Part 2)

Keras deep learning practice (15) -- realize Yolo target detection from scratch

322. Change

Honey, we are homeless now

Basic use of Pinia

C文件操作详解

轮播图van-swipe的报错:cannot read a properties of null(reading width)

MySQL sub database and sub table and its smooth expansion scheme

Babylon.js cool canvas background animation JS special effects
随机推荐
go IO操作-文件写
Binary tree traversal (day 74)
LeetCode-栈和队列刷题
Redux Usage Summary
Ugui source code analysis - imaskable
It's solved with a cry
summernote 字体显示中文
SkyWalking分布式系统应用程序性能监控工具-上
数据湖:开源数据湖方案DeltaLake、Hudi、Iceberg对比分析
Summernote font displays Chinese
【HDLBits 刷题】Verilog Language(2)Vectors 部分
PMP preparation experience | good habits, good process, good results
Tweenmax+svg Pikachu transformation ball
JVM initial
Is it safe for qiniu to open an account? Is the Commission of 30000 reliable?
Test interview questions
Xiaodi and Xiaohui
Keras deep learning practice (15) -- realize Yolo target detection from scratch
Symbol類型
Skywalking distributed system application performance monitoring tool - upper