D. Distance in Tree time limit per test 3 seconds memory limit per test 512 megabytes input standard input output standard output A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is the length (…
题目链接:http://codeforces.com/problemset/problem/161/D 题意:给出一个树,问树上点到点的距离为k的一共有几个. 一道简单的树形dp,算是一个基础题. 设dp[i][len]表示i为根距离为len的一共有几个点. 一般的树形dp都是先dfs然后再更新dp的值,注意按这样写就行了.而且一般的树形dp都是设dp[i][k]i为根,k为条件. void dfs(int u , int pre) { int len = vc[u].size(); dp[u]…
Tree Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 12276 Accepted: 3886 Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and v. Give an…
Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and Big Brother 题意:我也没看太清,就是给你两个10以内的数a,b.a每天乘以3,b每天乘以2,求多少天后a大于b. 思路:应该是有公式的,不过看到数据这么小直接暴力乘求解.官方题解貌似就是这样,数据小就是水题. const int N=1e3+10; int main() { int a…
VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx Solved: 2xx 题目连接 http://codeforces.com/contest/529/problem/E Description ATMs of a well-known bank of a sm…