Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
谁给点数据啊。样例过了照样wa的要死人了啊,最小点对求解函数哪里有问题?(内附点对分而治之的代码)/// <summary> /// 分而治之的方法进行点对的判断距离 /// </summary> /// <param name="l"></param> /// <param name="r"></param> /// <returns></returns> double mergepoint(int l,int r) { double resultl=0,resultr=0,minlen=10000000; if(r>l+2) { int mid=(l+r)>>1; double tempdis; resultl=mergepoint(l,mid); resultr=mergepoint(mid,r); minlen=min(resultl,resultr); for(int i=mid;i>=l&&point[i].x>point[mid].x-minlen;i--) { for(int j=mid;j<=r&&point[j].x<point[mid].x+minlen;j++) { if(point[i].type!=point[j].type) { tempdis=len(point[i],point[j]); if(tempdis<minlen) { minlen=tempdis; } } } } } else { double distemp; for(int i=l;i<r;i++) { for(int j=l+1;j<=r;j++) { if(j==i) { continue; } if(point[i].type!=point[j].type) { distemp=len(point[i],point[j]); minlen=minlen>distemp?distemp:minlen; } } } } return minlen; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator