![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
lca
WsMiracle
这个作者很懒,什么都没留下…
展开
-
POJ - 3728 The merchant
若买卖不在相邻城市,朴素的想法是遍历找出路径,然后找出路径上的最高最低价格得到价格差。然而每次光找路径就要耗费O(n)的时间,而题目中肯定有多个Query。用动态规划的思路解决问题,对指定两点uv,假设v往上走2^k步的父节点为t,走2^(k+1)步的父节点为u,如下图所示边上的数字表示深度之差。定义四个dp数组:int dp_max[MAX_LOG_V][MAX_V], dp_min[MAX_LO原创 2017-08-16 17:28:43 · 330 阅读 · 0 评论 -
POJ - 2763. Housewife Wind LCA+单点更新
After their royal wedding, Jiajia and Wind hid away in XX Village, to enjoy their ordinary happy life. People in XX Village lived in beautiful huts. There are some pairs of huts connected by bidirectio原创 2017-08-17 10:09:29 · 265 阅读 · 0 评论 -
HDU - 2874 Connections between cities (LCA Tarjan)
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <map>#include <vector>using namespace std;const int MaxN = 10000;struct node{ int v, w, next;}e[MaxN * 2 +原创 2017-08-04 16:50:29 · 371 阅读 · 0 评论 -
HDU - 3830 Checkers
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;struct node{ int x, y, z, d;}s, e;void run(node &u){ int num[3] = {u.x, u.y, u.z}; sort(n原创 2017-08-14 21:13:52 · 347 阅读 · 0 评论 -
Codeforces Round #425 (Div. 2) D. Misha, Grisha and Underground
#include #include #include #include #include #include using namespace std;const int MaxN = 1e5;int n, m;int depth[MaxN + 1];int f[MaxN + 1][20原创 2017-08-02 20:21:55 · 332 阅读 · 0 评论