题意:问树上两点之间的最短距离 解题关键:LCA模板题,在线做法,LCA->RMQ,用st表求解 这里是用first,rmq数组长度可以减半. #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<cmath> #include<iostream> typedef long long ll; using namespac…
hdu2586 How far away ? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4183 Accepted Submission(s): 1598 Problem Description There are n houses in the village and some bidirectional roads co…
How far away ? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 11739 Accepted Submission(s): 4325 Problem Description There are n houses in the village and some bidirectional roads connectin…
How far away ? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3653 Accepted Submission(s): 1379 Problem Description There are n houses in the village and some bidirectional roads connecting…