问题 说到k-means聚类算法,想必大家已经对它很熟悉了,它是基于距离计算的经典无监督算法,但是有一次在我接受面试时,面试官问了我一个问题:“k-means为什么不能使用曼哈顿距离计算,而使用欧式距离进行计算?”,当时我顿时懵了,心想:‘难道不都可以吗?’,我只能说都可以,然后面试官给了我一个眼神,“你回去查查吧,看看到底为什么”,然后我就回家啦.这是我后来在网上找到的回答,如下图: k-means基本思想: 1.在样本数据中随机设置n个聚类中心(Xi,Yi),假设数据只有二维: 2.计算样本…
题意是,给出n个k维空间下的点,然后q次操作,每次操作要么修改其中一个点的坐标,要么查询下标为[l,r]区间中所有点中两点的最大曼哈顿距离. 思路:参考blog:https://blog.csdn.net/Anxdada/article/details/81980574,里面讲了k维空间中的最大曼哈顿距离求法,然后利用这个方案改一改,用线段树来维护这些值就好了. #include<bits/stdc++.h> using namespace std; #define ll long long…
和去年多校的CSGO一样,用状态压缩来求Manhattan距离的最大值 然后要用线段树维护一下区间最大值 /* k维空间给定n个点,两个操作 1 i b1 b2 .. bk : 修改第i个点的坐标 2 l r:询问[l,r]区间点最大的曼哈顿距离 先考虑不带修: 线段树维护区间2^5种状态的最大值 查询时只要求出相对的两个状态的最大值即可 关于这个贪心的证明: 首先因为绝对值,所以aij前面带的符号可能是-也可能是+,总共就是有关2^k种可能 那么考虑每种状态 S 的最大值,加上相对这种状态 (…
Hyperspace Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1023    Accepted Submission(s): 492 Problem Description The great Mr.Smith has invented a hyperspace particle generator. The device i…
Hyperspace Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 314    Accepted Submission(s): 155 Problem Description The great Mr.Smith has invented a hyperspace particle generator. The device is…
Nightmare Ⅱ Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3012    Accepted Submission(s): 856 Problem Description Last night, little erriyue had a horrible nightmare. He dreamed that he and h…
题目链接 Problem Description You are playing CSGO. There are n Main Weapons and m Secondary Weapons in CSGO. You can only choose one Main Weapon and one Secondary Weapon. For each weapon, it has a composite score S. The higher the composite score of the…
Hyperspace Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 67    Accepted Submission(s): 32 Problem Description The great Mr.Smith has invented a hyperspace particle generator. The device is v…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3085 Nightmare Ⅱ Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2790    Accepted Submission(s): 781 Problem Description Last night, little erriyu…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3448    Accepted Submission(s): 1144 Problem Description It has been ten years since TJU-ACM established. And in this year all the retired TJU-ACM…