- 博客(6)
- 资源 (2)
- 收藏
- 关注
原创 UESTC 1717 LCA+DIJ
/* 第一次写最近公共祖先问题,用的邻接表指针。 对于一棵有根树,就会有父亲结点,祖先结点,当然最近公共祖先就是这两个点所有的祖先结点中深度最大的一个结点。 0 | 1 / \ 2 3 比如说在这里,如果0为根的话,那么1是2和3的父亲结点,0是1的父亲结点,0和1都是2和3的公共祖先结点,但是1才是最近的公共祖
2013-06-05 13:01:40 707
原创 hdu 4558 剑侠情缘
#include #include #include #include using namespace std; const int maxn=500; const int mod=1e9+7; int t,n,m,a[maxn][maxn]; int res,dp[maxn][maxn][12][2]; char map[maxn][maxn]; /* 我们定义: dp[i][j][key][0
2013-06-04 21:17:22 1042 1
原创 hdu 4547 Tarjan LCA 离线算法
题意,你网上搜搜吧。。。 解法就是LCA 离线模版变形题 #include #include #include #include #include #include #include using namespace std; const int maxn=100012;//node const int maxm=422222;//query int n,m,head[maxn],Head[
2013-06-04 17:39:02 916
原创 hdu 4568 dij+TSP
#include #include #include #include #include using namespace std; /* 类似 poj 3229 http://blog.csdn.net/azheng51714/article/details/8166632 有n个城市,规定m个城市必须去,求最短时间花费 每到一个城市要休息a[i]时间 ,先dij求得各点的最短距离,然后状态压缩D
2013-06-03 20:40:07 1341
原创 hdu 4571 Travel in time
Problem Description Bob gets tired of playing games, leaves Alice, and travels to Changsha alone. Yuelu Mountain, Orange Island, Window of the World, the Provincial Museum etc...are scenic spots
2013-06-03 10:50:03 1197
原创 hdu 4311 Meeting point-1
#include #include #include /* 题意:给你n个点问在其中任选一点到其他点的距离和最小是多少。 分析:|p1p2| = |x1 – x2| + |y1 – y2|; 看数据范围是不能暴力的。我们分开求,先求x方向的的最距离,然后在加上y方向上距离。 先把点按x排序,设排序后为X0,X1,X2,…,Xn-1。然后求每个点到x0的距离和sumx; 关键点在下面:我们在求
2013-06-01 14:44:18 865
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人