Roads in the North Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2359   Accepted: 1157 Description Building and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads are build such…
Roads in the North Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description Building and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads are build such that the…
题意: 给定一棵树, 求树的直径. 分析: 两种方法: 1.两次bfs, 第一次求出最远的点, 第二次求该点的最远距离就是直径. 2.同hdu2196的第一次dfs, 求出每个节点到子树的最长距离和次长距离, 然后某个点的最长+次长就是直径. #include<stdio.h> #include<vector> #include<algorithm> #include<string.h> #include<iostream> using name…
Building and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads are build such that there is only one route from a village to a village that does not pass through some other village twice. Give…
Building and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads are build such that there is only one route from a village to a village that does not pass through some other village twice. Give…
题目链接: C2. Brain Network (medium) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Further research on zombie thought processes yielded interesting results. As we know from the previous prob…
Roads in the North Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2389   Accepted: 1173 Description Building and maintaining roads among communities in the far North is an expensive business. With this in mind, the roads are build such…
Labyrinth Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 4004   Accepted: 1504 Description The northern part of the Pyramid contains a very large and complicated labyrinth. The labyrinth is divided into square blocks, each of them eithe…
Labyrinth 题目链接: http://acm.hust.edu.cn/vjudge/contest/130510#problem/E Description The northern part of the Pyramid contains a very large and complicated labyrinth. The labyrinth is divided into square blocks, each of them either filled by rock, or f…
比较经典的老题 题目意思:给你一颗节点数为n的树,然后其中m个特殊点,再给你一个值d,问你在树中有多少个点到这m个点的距离都不大于d. 这题的写法有点像树的直径求法,先随便选择一个点(姑且设为点1)来遍历一遍树,存下所有点到点1的距离.然后在m个特殊点中找到距离点1最远的点a1. 然后以a1为初始点遍历一遍树,求每一个点到a1的距离,存在dp[i]中.并且再在m个点中找到到a1距离最大的点a2.最后再以a2为初始点遍历一遍树,求到每一个点到a2的距离dp1[i].然后for遍历所有点,如果dp[…