妈呀我真是不知道怎么了裸题都要写挂~~~正宗倍增LCA啊~~~把bfs换成dfs就好了不知道为什么。 #include<iostream>#include<cstdio>#include<cstring>#include<queue>#include<cmath>#define maxv 10000
分类:
其他好文 时间:
2016-02-09 15:05:03
阅读次数:
320
这题做了几个小时,基本思路肯定是求两点路径中的割点数目,思路是tarjan缩点,然后以割点和连通块作为新节点见图。转化为lca求解。结合点——双连通分量与LCA。 1 /* 3686 */ 2 #include <iostream> 3 #include <sstream> 4 #include <
分类:
其他好文 时间:
2016-02-06 01:41:18
阅读次数:
291
LCA+RMQ。挺不错的一道题目。 思路是如何通过LCA维护费用。当加入新的点u是,费用增量为dis[u]-dis[lca(u, lower_u)] - dis[lca(u, greater_u)] + dis[lca(lower_u, greater_u)]。若beg[u]大于当前最大值或小于最小
分类:
其他好文 时间:
2016-02-05 18:35:21
阅读次数:
220
Journey Time Limit: 15000/3000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Bob has traveled to byteland, he find the N cities in bytelan
分类:
其他好文 时间:
2016-02-02 16:14:26
阅读次数:
172
2819: Nim Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 1596 Solved: 597[Submit][Status][Discuss] Description 著名游戏设计师vfleaking,最近迷上了Nim。普通的Nim游戏为:两个人
分类:
其他好文 时间:
2016-01-31 21:44:24
阅读次数:
332
Distance Queries Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 11304 Accepted: 3985 Case Time Limit: 1000MS Description Farmer John's cow
分类:
其他好文 时间:
2016-01-31 02:45:37
阅读次数:
199
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes
分类:
其他好文 时间:
2016-01-30 18:28:44
阅读次数:
135
综合性很强的题目。存在环,可以用tarjan处理,然后需要求LCA。并查集+RMQ可以搞。非常不错的题目。 1 /* 4297 */ 2 #include <iostream> 3 #include <sstream> 4 #include <string> 5 #include <map> 6 #
分类:
其他好文 时间:
2016-01-30 18:23:08
阅读次数:
163
Nearest Common Ancestors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 23388 Accepted: 12195 Description A rooted tree is a well-known da
分类:
其他好文 时间:
2016-01-30 13:36:38
阅读次数:
147