博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[hdu4347]The Closest M Points(平衡树式kdtree)
阅读量:4562 次
发布时间:2019-06-08

本文共 1053 字,大约阅读时间需要 3 分钟。

解题关键:模板题(结合起来了)

#include
#include
#include
#include
#include
#include
#include
#define N 50050#define inf (1<<30)#define sq(x) (x)*(x)using namespace std;int n,m,dim,rt,k;struct node{ int p[10],minn[10],maxx[10]; bool operator<(const node &u)const{ return p[dim]
PDN;priority_queue
que;struct kd_tree{ int c[N][2]; node s[N],q; void update(int o){ //管辖范围 int l=c[o][0],r=c[o][1]; for(int i=0;i
t.p[i])tmp+=sq(s[o].minn[i]-t.p[i]); if(t.p[i]>s[o].maxx[i])tmp+=sq(t.p[i]-s[o].maxx[i]); } return tmp; } void build(int &o,int l,int r,int now){ o=(l+r)>>1;now%=k;dim=now; nth_element(a+l,a+o,a+r+1); add(o,a[o]); if(l!=o) build(c[o][0],l,o-1,now+1); if(o!=r) build(c[o][1],o+1,r,now+1); update(o); } void ins(int o,int now){ now%=k; if(q.p[now]
tmp.first){ que.pop(); que.push(tmp); } } int dl=c[o][0]?dist(q,c[o][0]):inf,dr=c[o][1]?dist(q,c[o][1]):inf; if(dl
0;i--){ for(int j=0;j

 

转载于:https://www.cnblogs.com/elpsycongroo/p/10493541.html

你可能感兴趣的文章
手机整机方案公司之测试业务流程
查看>>
HeadFIrst Ruby 第二章总结 methods and classes
查看>>
STM32 通用定时器相关寄存器
查看>>
【题解】1621. 未命名
查看>>
字符串加密算法
查看>>
Oracle的实例恢复解析
查看>>
UICollectionView cellForItemAt 不被调用
查看>>
巧用网盘托管私人Git项目
查看>>
python全栈脱产第19天------常用模块---shelve模块、xml模块、configparser模块、hashlib模块...
查看>>
[LeetCode] House Robber
查看>>
virtualbox中kali虚拟机安装增强功能
查看>>
java生成六位验证码
查看>>
iOS的MVP设计模式
查看>>
stringstream
查看>>
【转】HDU 6194 string string string (2017沈阳网赛-后缀数组)
查看>>
前后端分离
查看>>
渗透测试学习 一、环境搭建
查看>>
处理图片透明操作
查看>>
Postman-OAuth 2.0授权
查看>>
mac pycharm打不开问题
查看>>