题目大意:给你一棵树,其中点上和边上都有值。定义2-Path为经过一条边最多两次的路径,价值为经过点的权值加和-经过边权值*该边经过次数。4e5组询问,每次询问树上连接x,y两点的2-Path的最大价值。 题解: 一道状态比较多的树形dp。 dp1:记录x点子树内从x到x的最大2-Path的价值-x ...
分类:
其他好文 时间:
2018-11-01 11:45:02
阅读次数:
152
poj1942 Paths on a Grid 题意:给定一个长m高n$(n,m \in unsigned 32-bit)$的矩形,问有几种走法。$n=m=0$时终止。 显然的$C(m+n,n)$ 但是没有取模,n,m的范围又在unsigned int 范围内 于是有一种神奇的方法↓↓ 1 #inc ...
分类:
其他好文 时间:
2018-10-31 15:45:22
阅读次数:
132
发现从顶点入手不太方便,我们从这个“公共部分最长”开始考虑问题,因为要求这一条公共部分的链最长,可以联想到树的直径,那么本题就是要求一条类似于直径的东西使两个端点除了直径这一条链之外还有不少于两个的儿子,我们只要把这两个儿子交叉输出一下就得到了本题的答案。只要两次$dfs$就可以分别求出这一条链的两 ...
分类:
其他好文 时间:
2018-10-28 11:12:43
阅读次数:
102
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4098 [算法] 显然 , 回文路径中第i个字母的位置(x , y)必然满足 : x + y - 1 = i 用f[i][j][k]表示现在在第i步 , 左上的横坐标为j , 右下的横坐 ...
分类:
其他好文 时间:
2018-10-25 00:12:40
阅读次数:
183
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p ...
分类:
其他好文 时间:
2018-10-21 14:17:22
阅读次数:
175
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p ...
分类:
其他好文 时间:
2018-10-20 23:45:12
阅读次数:
159
原文:零元学Expression Design 4 - Chapter 6 教你如何在5分钟内做出文字立体感效果 又来一篇五分钟做设计啦~ 本篇将教大家如何运用Design内建工具Blend Paths在五分钟内作出超炫效果 ?... ...
分类:
其他好文 时间:
2018-10-17 00:10:58
阅读次数:
152
You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need t ...
分类:
其他好文 时间:
2018-10-15 18:16:12
阅读次数:
167
题意:有n个点,m条路,问你最少加几条边,让整个图变成边双连通分量。 思路:缩点后变成一颗树,最少加边 = (度为1的点 + 1)/ 2。3177有重边,如果出现重边,用并查集合并两个端点所在的缩点后的点。 代码: ...
分类:
其他好文 时间:
2018-10-13 02:31:43
阅读次数:
138