HDU 5626 Clarke and points 求平面最远哈曼顿距离
来源:互联网 发布:mac上好用的vpn 知乎 编辑:程序博客网 时间:2024/06/05 03:08
题意:根据题意给一个函数能得到一个点的数组,然后求所有点中最远的哈曼顿距离
思路:哈曼顿距离是|Xa-Xb|+|Ya-Yb|,这里看数据就知道不能裸跑,我们可以讨论绝对值内的正负,然后会出现四种情况,整理得到(Xa+Ya)-(Xb+Yb),(Xa-Ya)-(Xb-Yb),(-Xa+Ya)-(-Xb+Yb),(-Xa-Ya)-(-Xb-Yb)
(比赛的时候稍微算了一下,感觉nlogn能过,然后就T了QAQ
这里保存一下每个状态的最大最小就OK了
#include<map>#include<set>#include<queue>#include<stack>#include<math.h>#include<string>#include<vector>#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm> using namespace std;typedef long long LL;#define maxn 1000005#define f(x) (x*1.0)#define inf 0x7fffffff#define maxm maxn*maxn#define min(a,b) (a>b?b:a)#define max(a,b) (a>b?a:b)#define lowbit(x) (x&(-x))#define cheak(i) printf("%d ",i)#define lson(x) (splay[x].son[0])#define rson(x) (splay[x].son[1])#define rfor(i,a,b) for(i=a;i<=b;++i)#define lfor(i,a,b) for(i=a;i>=b;--i)#define mem(a,b) memset(a,b,sizeof(a))#define mec(a,b) memcpy(a,b,sizeof(b))struct node{ LL x,y;}A[maxn];LL B[maxn];long long seed;inline long long rand(long long l, long long r) { static long long mo=1e9+7, g=78125; return l+((seed*=g)%=mo)%(r-l+1);}int main(){ int T,i; LL n; scanf("%d",&T); while(T--) { scanf("%lld%lld",&n,&seed); LL Min1=inf,Min2=inf,Min3=inf,Min4=inf,Max1=-inf,Max2=-inf,Max3=-inf,Max4=-inf; rfor(i,1,n) { A[i].x = rand(-1000000000, 1000000000), A[i].y = rand(-1000000000, 1000000000); Min1=min(Min1,A[i].x+A[i].y);Max1=max(Max1,A[i].x+A[i].y); Min2=min(Min2,A[i].x-A[i].y);Max2=max(Max2,A[i].x-A[i].y); Min3=min(Min3,-A[i].x+A[i].y);Max3=max(Max3,-A[i].x+A[i].y); Min4=min(Min4,-A[i].x-A[i].y);Max4=max(Max4,-A[i].x-A[i].y); //printf("%lld %lld\n",A[i].x,A[i].y); } LL ans=0; ans=max(ans,Max1-Min1); ans=max(ans,Max2-Min2); ans=max(ans,Max3-Min3); ans=max(ans,Max4-Min4); printf("%lld\n",ans); } return 0;}
0 0
- HDU 5626 Clarke and points 求平面最远哈曼顿距离
- hdu 5626 Clarke and points 最大曼哈顿距离
- HDU 5626 Clarke and points(最大曼哈顿距离)
- HDU 5626 Clarke and points
- HDU 5626 Clarke and points
- HDU 5626 Clarke and points
- hdu 5626 Clarke and points
- hdoj 5626 Clarke and points (曼哈顿距离)
- HDU Clarke and points
- HDU 5626 Clarke and points(二进制枚举)
- 杭电hdu 5626 Clarke and points【思维】
- hdoj 5626 Clarke and points 【思维】
- HDU5626 Clarke and points
- 平面最远哈密顿距离
- 平面最远点对距离
- bestcoder #72Clarke and points
- hdoj Clarke and points 5626 (数学&变换)
- HDU 4666 经典的求最远曼哈顿距离
- 在 Eclipse 中通过 SSH 密钥登录远程服务器
- web工程引入Spring
- SiteMesh+Freemarker
- Android中如何禁用其他应用,并且不在桌面显示
- java基础总结 --- 泛型 擦除、边界、通配符、
- HDU 5626 Clarke and points 求平面最远哈曼顿距离
- CSS中bottom与margin-bottom的区别
- CentOS 6.5下Git服务器搭建
- 图解:麦肯锡工作术!
- SQL 中 SELECT 语句的执行顺序
- iOS不规则控件的点击事件
- 算法学习--数学相关
- 名詞解釋
- win8和win7下解决php5.3和5.4、5.5等不能加载php_curl.dll的终极解决办法