1787: [Ahoi2008]Meet 紧急集合 Description Input Output Sample Input 6 4 1 2 2 3 2 4 4 5 5 6 4 5 6 6 3 1 2 4 4 6 6 6 Sample Output 5 2 2 5 4 1 6 0 【题解】 记住一 ...
                            
                            
                                分类:
其他好文   时间:
2016-10-18 11:22:55   
                                阅读次数:
178
                             
                    
                        
                            
                            
                                    bzoj1787[Ahoi2008]Meet 紧急集合 题意: 给个树,每次给三个点,求与这三个点距离最小的点。 题解: 倍增求出两两之间的LCA后,比较容易理解的做法是挑出两个LCA再做一次LCA,比较所有挑法。但画kan出ti图jie可知其中有两个LCA是相等的,而所求就是那个与它们不等的LCA ...
                            
                            
                                分类:
其他好文   时间:
2016-07-20 21:19:03   
                                阅读次数:
201
                             
                    
                        
                            
                            
                                lca。 3个点分别lca,可以知道,深度最深的lca就是答案。 #include #include #include using namespace std; const int maxn = 500000 + 10; const int maxm = 1000000 + 10; const in... ...
                            
                            
                                分类:
其他好文   时间:
2016-06-09 00:37:08   
                                阅读次数:
168
                             
                    
                        
                            
                            
                                    求三个结点到一个结点距离之和最小的结点以及距离和 求出两两lca,其中有两个相同,答案则为另一个 感觉就是一大暴力。。。 ...
                            
                            
                                分类:
其他好文   时间:
2016-05-14 23:10:11   
                                阅读次数:
202
                             
                    
                        
                            
                            
                                题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1787DescriptionInputOutputLCA水过三个点两两求LCA,若有其中两个LCA一样“集合点”就是第三个LCA多加inline有用处,DFS改BFS对效率没有什么提高从上到下...
                            
                            
                                分类:
其他好文   时间:
2015-12-26 15:08:27   
                                阅读次数:
198
                             
                    
                        
                            
                            
                                DescriptionInputOutputSample Input6 4 1 2 2 3 2 4 4 5 5 6 4 5 6 6 3 1 2 4 4 6 6 6 Sample Output 5 2 2 5 4 1 6 0 HINTSourceDay1只有3个点可能取到最优解,分别是3个点中任选两个...
                            
                            
                                分类:
其他好文   时间:
2015-08-02 16:48:14   
                                阅读次数:
106
                             
                    
                        
                            
                            
                                水题 求出三个人每两个间的LCA,然后最小花费就是两两点之间的路径长度之和除以2 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn = 500005; 6 struct edge{ 7 in...
                            
                            
                                分类:
其他好文   时间:
2015-07-31 23:25:48   
                                阅读次数:
150
                             
                    
                        
                            
                            
                                题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1787刚开始好像很难的样子画了一下,发现好像只有3种情况,且最终的P点一定是两两LCA中的一个。裸的LCA怪不得数据那么大#include#include#include#include#incl...
                            
                            
                                分类:
其他好文   时间:
2015-07-18 18:21:38   
                                阅读次数:
100
                             
                    
                        
                            
                            
                                题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1787
题解:
求出三个点两两之间的lca会发现有两个是一样的,然后我们选那个不一样的就好了。
#include
#include
#include
#include
using namespace std;
struct use{
  int st,en;	
}b[5000001];...
                            
                            
                                分类:
其他好文   时间:
2015-05-25 22:39:25   
                                阅读次数:
130
                             
                    
                        
                            
                            
                                简述求LCA的倍增算法 对于树上的所有节点,我们可以很轻松地通过dfs求出其直接的父亲节点以及其深度 通过类似RMQ的原理我们可以处理出每个节点的第2^i个父亲 //这个过程既可以在dfs之后双重循环建也可以像树剖模板里那样dfs里直接建 //个人比较推荐后者,会少掉一些不必要的运算,但由于...
                            
                            
                                分类:
编程语言   时间:
2015-04-15 12:55:45   
                                阅读次数:
148