
换根dp
换根dp
_sky123_
这个作者很懒,什么都没留下…
展开
-
2020CCPC威海 C. Rencontre
题目链接Located at the easternmost tip of Shandon Peninsula, Weihai is one of the most famous tourist destinations all over China. There are beautiful hills, seas, bays, springs, islands, and beautiful beaches in Weihai. It is also a coastal city abundant in原创 2020-12-18 08:44:49 · 349 阅读 · 0 评论 -
Codeforces Round #658 (Div. 1) The Majestic Brown Tree Snake
There is an undirected tree of nnn vertices, connected by n−1n−1n−1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex aaa and its tail is at vertex bbb. The snake’s body occupies all vertices on the unique simple p原创 2020-08-13 11:16:42 · 489 阅读 · 0 评论 -
G. Directing Edges
You are given an undirected connected graph consisting of nnn vertices and mmm edges. kkk vertices of this graph are special.You have to direct each edge of this graph or leave it undirected. If you leave the iii-th edge undirected, you pay wiw_iwi coins原创 2020-08-12 16:05:03 · 297 阅读 · 0 评论 -
Maximum White Subtree
You are given a tree consisting of n vertices. A tree is a connected undirected graph with n−1 edges. Each vertex v of this tree has a color assigned to it (av=1 if the vertex v is white and 0 if the ...原创 2020-03-26 15:15:55 · 233 阅读 · 0 评论 -
选根
有一颗有nnn个结点树,结点被编号为111~nnn,记根结点深度为111,如果第iii个结点的深度是ddd,则它贡献的价值是d×wid\times{w_i}d×wi ,这棵树的价值是所有结点的价值和 求当根结点为111~nnn时,树的价值分别为多少输入描述第一行输入一个整数TTT,代表有TTT组测试数据 对于每一组测试数据,第一行有111个整数nnn,第二行有nnn个整数wiw_iwi,接下来n−1n-1n−1行每行有两个整数x,yx,yx,y表示xxx和yyy之间有一条边输出描述对于每组测试原创 2020-06-08 13:11:11 · 204 阅读 · 0 评论 -
Radio Prize(二次扫描与换根法)
All boring tree-shaped lands are alike, while all exciting tree-shaped lands are exciting in their own special ways.What makes Treeland more exciting than the other tree-shaped lands are the raddest r...原创 2020-05-04 22:06:30 · 542 阅读 · 0 评论