【马上就要期末考试了,这两天再写个几题估计就要滚粗去搞文化课了qaq】拿到这道题很容易能够联想到LCA。。然而我这个大弱智一开始想当然地求了三个点的LCA,然后发现连样例都过不去。。实际上这很显然是错误的,画个图模拟一下样例就知道了。然后去搜题解。题解说对三个点两两求LCA,在得到的三个LCA中枚举...
分类:
其他好文 时间:
2016-01-04 21:04:15
阅读次数:
323
1787: [Ahoi2008]Meet 紧急集合Time Limit: 20 SecMemory Limit: 162 MBSubmit: 1841Solved: 857[Submit][Status][Discuss]Description Input Output Sample Input6 ...
分类:
其他好文 时间:
2016-01-03 18:27:41
阅读次数:
150
这道题不难,就是3个点的lca。算法有点多,写成树链剖分的吧!跑完2400多毫秒。还好,挺顺利的,加油!努力啊!注意看数据范围!相信自己,能行的 1 #include 2 #include 3 #include 4 #define rep(i,j,k) for(int i = j; i = k;.....
分类:
其他好文 时间:
2015-12-29 21:13:04
阅读次数:
222
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1787DescriptionInputOutputLCA水过三个点两两求LCA,若有其中两个LCA一样“集合点”就是第三个LCA多加inline有用处,DFS改BFS对效率没有什么提高从上到下...
分类:
其他好文 时间:
2015-12-26 15:08:27
阅读次数:
198
DescriptionSample 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 Output5 2 2 5 4 1 6 0 思路:唔,直接暴力求出三个lca判断一下哪个lca是题目所要求的点就好了 1 #include 2 ...
分类:
其他好文 时间:
2015-09-10 00:17:07
阅读次数:
252
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
这道题用 LCA 就可以水过去 , 但是我太弱了 QAQ 倍增写LCA总是写残...于是就写了树链剖分...其实也不难写 , 线段树也不用用到 , 自己YY一下然后搞一搞就过了...速度还挺快的好像= = #9---------------------------------------------...
分类:
其他好文 时间:
2015-06-14 12:26:36
阅读次数:
132
1789: [Ahoi2008]Necklace Y型项链Time Limit: 20 SecMemory Limit: 256 MB题目连接http://www.lydsy.com/JudgeOnline/problem.php?id=1789Description欢乐岛上众多新奇的游乐项目让小可...
分类:
其他好文 时间:
2015-05-28 17:58:24
阅读次数:
173
题目链接: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