当前位置:
首页 >
Codeforces Round #703 (Div. 2) B.Eastern Exhibition 中位数结论
发布时间:2023/12/4
56
豆豆
生活随笔
收集整理的这篇文章主要介绍了
Codeforces Round #703 (Div. 2) B.Eastern Exhibition 中位数结论
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
link
题意: 给n个点,求有多少个点到所有点距离之和最小。
中位数结论题了,可以考虑一维的情况,让后二维的话乘起来就好啦。
//#pragma GCC optimize(2) #include<cstdio> #include<iostream> #include<string> #include<cstring> #include<map> #include<cmath> #include<cctype> #include<vector> #include<set> #include<queue> #include<algorithm> #include<sstream> #include<ctime> #include<cstdlib> #define X first #define Y second #define L (u<<1) #define R (u<<1|1) #define pb push_back #define mk make_pair #define Mid (tr[u].l+tr[u].r>>1) #define Len(u) (tr[u].r-tr[u].l+1) #define random(a,b) ((a)+rand()%((b)-(a)+1)) #define db puts("---") using namespace std;//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); } //void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); } //void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int> PII;const int N=1000010,mod=1e9+7,INF=0x3f3f3f3f; const double eps=1e-6;int n; int x[N],y[N];int main() { // ios::sync_with_stdio(false); // cin.tie(0);int _; scanf("%d",&_);while(_--){scanf("%d",&n);for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&y[i]);sort(x+1,x+1+n); sort(y+1,y+1+n);LL a=x[n/2+1]-x[n/2]+1;LL b=y[n/2+1]-y[n/2]+1;if(n%2==1) a=1,b=1;printf("%lld\n",a*b);}return 0; } /**/总结
以上是生活随笔为你收集整理的Codeforces Round #703 (Div. 2) B.Eastern Exhibition 中位数结论的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 《英雄联盟》S13 全球总决赛 T1 战
- 下一篇: Codeforces Round #70