icpc:problems:703b_eastern_exhibition
problems | |
---|---|
名称 | Eastern Exhibition |
题目编号 | 703B |
题目链接 | codeforces.com/… |
来源 | CodeForces |
算法分类 | 数学 |
难易程度 | 容易 |
Eastern Exhibition
想法
如果改变一个坐标的x,你会发现所有的y还是原来的y。没有改变。
所以我们要找路径最小,那就找最中间的区域。也就是x最中间与y最中间的区域。
代码实现
#include<cstdio> #include<algorithm> int x[1010], y[1010]; int main() { int T; scanf("%d", &T); for(int t=1; t<=T; ++t) { int n; scanf("%d", &n); for(int i=1; i<=n; ++i) scanf("%d %d", &x[i], &y[i]); if(n == 1) { printf("1\n"); continue; } std::sort(x+1, x+1+n); std::sort(y+1, y+1+n); int s1 = (n+1)/2, s2 = (n+2)/2; printf("%lld\n", (long long int)(x[s2]-x[s1]+1)*(y[s2]-y[s1]+1)); } return 0; }
/app/www/public/data/pages/icpc/problems/703b_eastern_exhibition.txt · 最后更改: 2023/10/01 10:07 由 温婕莺