#include<bits/stdc++.h>using namespace std;int n,k;vector<int>son[1000007];int dp[1000007],depth[1000007],ans[1000007];//dp【i】表示离i最近的叶子节点距离i的深度,depth【 ...
分类:
其他好文 时间:
2018-10-24 00:58:39
阅读次数:
127
两次dfs,第一次处理处fa[],depth[],size[],son[],第二次处理出top[],rank[],id[] 一条重链的编号是连续的,可以用数据结构维护,做事情的时候判断是否在同一条链上,不是就把最深的跳到链头的fa[],然后继续判断 luogu3384 【模板】树链剖分 区间加,求和 ...
分类:
其他好文 时间:
2018-10-18 10:48:45
阅读次数:
139
Linux下的根分区使用率100%,但是查看/分区下的目录都不大,没有占用满,这该怎么处理? 切到根目录,运行du -h --max-depth=1发现文件实际大小加起来才不到30%,这时就有可能是有文件被删除,而进程还活着,因而造成还占用空间的现象。lsof |grep delete 根据lsof ...
分类:
其他好文 时间:
2018-10-16 13:33:00
阅读次数:
215
今天发现一个服务器的/opt目录数据过大,最后发现是tomcat中的catalina.out日志过大引起的 用du命令查看opt下一层的数据文件大小 [root@ccssapportalp opt]# du -h --max-depth=1 /opt 最终发现在tomcat里catalina.out ...
分类:
其他好文 时间:
2018-10-16 11:56:10
阅读次数:
199
Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest le ...
分类:
其他好文 时间:
2018-10-14 20:53:01
阅读次数:
102
"104. Maximum Depth of Binary Tree Easy" 方法 使用递归 Time complexity : we visit each node exactly once, thus the time complexity is \mathcal{O}(N)O(N), wh ...
分类:
编程语言 时间:
2018-10-13 16:50:35
阅读次数:
228
我对DFS的理解 [何为DFS] 深度优先搜索(Depth-First-Search),简称DFS。是一种常见搜索算法。其方法是从原点不断一条路扩散,当无路可走时回退来走下一条路,直至找到目标或遍历。 [框架] [我对DFS的理解] DFS其实十分简单。它的主旨就是只考虑当下怎么走,换句话说就是每次 ...
分类:
其他好文 时间:
2018-10-13 02:39:51
阅读次数:
140
时间限制:1秒 空间限制:32768K 热度指数:96213 本题知识点: 树 算法知识视频讲解 题目描述 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the s ...
分类:
其他好文 时间:
2018-10-13 02:39:42
阅读次数:
138
https://leetcode.com/problems/maximum-depth-of-n-ary-tree/description/ 非常简单的题目,连edge case 都没有。思路就是:最大深度 = 孩子的最大深度 + 1 ...
分类:
其他好文 时间:
2018-10-11 11:35:39
阅读次数:
164
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l ...
分类:
其他好文 时间:
2018-10-09 21:36:02
阅读次数:
138