思路染色问题,可以使用dfs,也可以使用bfs代码class Solution { boolean valid = true; int[][] graph; public boolean isBipartite(int[][] graph) { this.graph = graph; int n =... ...
分类:
其他好文 时间:
2020-07-16 21:42:04
阅读次数:
58
如果只要求判断有没有解的话很好做:以条树边被两条非树边覆盖即可. 输出方案的话可以考虑碰到一条非树边就暴力覆盖. 如果覆盖的过程中发现一条边已经被覆盖了就输出结果. 由于一条边只能被一种非树边覆盖,所以复杂度均摊下来是 $O(n)$ 的. 然后我们就得到两条路径 $(a,b)$ 与 $(c,d)$, ...
分类:
其他好文 时间:
2020-07-16 12:02:17
阅读次数:
55
一个数最多能取8-9次根号。 #include <bits/stdc++.h> using namespace std; #define debug printf("bug!!!\n"); typedef long long ll; const int MAXN=1e5+10; const ll M ...
分类:
其他好文 时间:
2020-07-16 10:11:53
阅读次数:
74
链接:https://leetcode-cn.com/problems/subsets-ii/ 代码 class Solution { public: vector<vector<int>> ans; vector<int> path; vector<vector<int>> subsetsWith ...
分类:
其他好文 时间:
2020-07-16 00:27:10
阅读次数:
75
今天听了ztcdl的讲解,队友lkt,cyx带了我几道模板题,突然感觉自己行了,特写下强连通分量板子。(可能自己还没睡醒,有勇气写板子了) 强连通分量的预备姿势: ①树上的DFS序(时间戳):一句话,就是按照dfs的遍历顺序,把每个点再对应一个dfn数组,dfn[i]存的就是dfs序的时间戳。 ②D ...
分类:
其他好文 时间:
2020-07-15 23:56:52
阅读次数:
76
Description A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. ...
分类:
其他好文 时间:
2020-07-15 23:20:22
阅读次数:
96
public boolean isBalanced(TreeNode root) { if (root == null) { return true; } int diff = getDepth(root.left) - getDepth(root.right); diff = diff > 0 ? ...
分类:
其他好文 时间:
2020-07-15 22:51:05
阅读次数:
53
class Solution { public int longestConsecutive(TreeNode root) { dfs(root); return res; } private int res = 0; public int[] dfs(TreeNode root) { // 以ro ...
分类:
其他好文 时间:
2020-07-14 18:25:06
阅读次数:
49
class Solution { public int maxPathSum(TreeNode root) { dfs(root); return res; } int res = Integer.MIN_VALUE; public int dfs(TreeNode root) { // 返回以当前 ...
分类:
其他好文 时间:
2020-07-14 18:15:42
阅读次数:
58
这个事情的背景是公司的Hadoop生态集群都是原生的,不是基于CDH的,所以基本所有的东西都需要自己手动管理,比如集群修改一些属性,然后批量分发重启或者动态生效之类的。这次也算不上事故,因为没对生产环境造成什么影响,但是差一点就变成事故,写出来分享一下。 事情简单概括就是,60+台hadoop的集群 ...
分类:
其他好文 时间:
2020-07-14 13:10:45
阅读次数:
72