随笔分类 -  数据结构--LCA

摘要:xor There is a tree with nn nodes. For each node, there is an integer value a_ia​i​​, (1 \le a_i \le 1,000,000,0001≤a​i​​≤1,000,000,000 for 1 \le i \l 阅读全文
posted @ 2017-09-19 14:59 贱人方 阅读(602) 评论(0) 推荐(0)
摘要:Phone Call Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 156 Accepted Submission(s): 67 Probl 阅读全文
posted @ 2017-08-05 11:19 贱人方 阅读(532) 评论(0) 推荐(0)
摘要:RXD, tree and sequence Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 234 Accepted Submission( 阅读全文
posted @ 2017-08-02 23:08 贱人方 阅读(547) 评论(0) 推荐(0)
摘要:Misha, Grisha and Underground time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Misha and 阅读全文
posted @ 2017-07-29 21:16 贱人方 阅读(349) 评论(0) 推荐(0)
摘要:A and B and Lecture Rooms time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A and B are pr 阅读全文
posted @ 2017-07-23 22:15 贱人方 阅读(239) 评论(0) 推荐(0)
摘要:【题意】给你N个点,N条不同的边,Q次询问,求出u,v之间的最短路。 【分析】题意很简单,就是求最短路,但是Q次啊,暴力DIJ?当然不行,观察到这个题边的数目和点的数目是相同的,也就是说这个图是由一棵树加了一条边而形成的。而对于一棵树,如果有Q次询问最短路,那就可以用LCA来做,复杂度QlogN,但 阅读全文
posted @ 2017-04-15 18:36 贱人方 阅读(427) 评论(0) 推荐(0)
摘要:COT - Count on a tree #tree #tree You are given a tree with N nodes.The tree nodes are numbered from 1 to N.Each node has an integer weight. We will a 阅读全文
posted @ 2017-02-07 16:04 贱人方 阅读(391) 评论(0) 推荐(0)
摘要:Query on a tree II You are given a tree (an undirected acyclic connected graph) with N nodes, and edges numbered 1, 2, 3...N-1. Each edge has an integ 阅读全文
posted @ 2017-01-28 20:01 贱人方 阅读(464) 评论(0) 推荐(0)
摘要:Distance Queries Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 12950 Accepted: 4577 Case Time Limit: 1000MS Description Farmer John's cow 阅读全文
posted @ 2016-12-10 16:27 贱人方 阅读(454) 评论(0) 推荐(0)