Total Accepted: 701 Total Submissions: 1714 Difficulty: Medium A group of two or more people wants to meet and minimize the total travel distance. You ...
分类:
其他好文 时间:
2016-08-05 06:23:16
阅读次数:
107
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5441
思路:离线处理。将边权值按从小到大排序,查询标号后按照从小到大排序。对于每次查询,依次将比当前查询值小的边加入并查集。对于两个符合条件即将合并的连通块增加答案个数num[x]*num[y]*2 。合并:fa[x]=y; num[y]+=num[x]; 。最后依次输出结果即可。
#incl...
分类:
其他好文 时间:
2016-08-05 01:04:31
阅读次数:
130
You want to visit a strange country. There are n cities in the country. Cities are numbered from 1 to n. The unique way to travel in the country is ta ...
分类:
其他好文 时间:
2016-07-31 15:55:52
阅读次数:
167
题目链接:点击打开链接
思路:
题目要求有多少对点(a, b)使得a到b的最短路上最长边不超过x。 我们将边从小到大排序, 用并查集来维护关系, 这样, 对于当前加入集合的一条边(a, b),权值为c, 他就是当前集合的最长边, 那么不大于c的对数就是就是这两个集合的个数的组合。 预处理一下即可。
细节参见代码:
#include
#include
#include
#include...
分类:
其他好文 时间:
2016-07-31 14:36:22
阅读次数:
217
Travel Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64u /*神测试数据。。。。。【 T。T 】 15 5 122 3 63341 5 157243 5 57054 3 123821 3 21726633 ...
分类:
其他好文 时间:
2016-07-25 18:15:26
阅读次数:
268
题目 二维平面上有n个点,每个点的横纵坐标均为非负整数。两个点之间的距离记为 min(abs(x1 - x2), abs(y1 - y2)),求从点1到达点n的最短路径长度。 比较容易想到使用最短路径算法来解决,但关键的问题是如何建图!参考了网上的代码http://blog.csdn.net/che ...
分类:
其他好文 时间:
2016-07-19 23:24:18
阅读次数:
188
Travel imparts new vigor to the mind. 旅行能给思想带来新的活力。 Travel can give us opportunities to experience many different things, such as getting acquainted w ...
分类:
其他好文 时间:
2016-07-13 15:51:11
阅读次数:
137
更优雅的异步编程: 定向爬取 :http://www.010xww.com/list/travel.htm 上代码: 打印一下http 。 嗯 http 模块加载没问题 ...
分类:
Web程序 时间:
2016-06-25 15:01:26
阅读次数:
116
题目:给出一个长度为n的数轴和一个初始方向,一个人一次可以走[1,m]步,走到头就会自动反弹回来,求给定起点X到Y的期望步数 E[x]表示x点到终点的期望,则E[x]=sigma(E[x+i]+i),E[Y]=0 因为还有方向问题,所以我们把n个点拆成2*n-2个,原数轴01234变成0123432 ...
分类:
其他好文 时间:
2016-05-23 13:14:46
阅读次数:
93
先处理出最短路上的边。变成一个DAG,然后在DAG上进行DFS。 ...
分类:
其他好文 时间:
2016-05-19 21:09:41
阅读次数:
177