This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 输出图中的所有的环 | |
//color label :white(not visited),black(all children have been visited),gray(start visiting node) | |
// if one edge direct to a gray node means has cycle. | |
#include <bits/stdc++.h> | |
using namespace std; | |
const int maxn = 1e5+3; | |
vector<int>g[maxn]; | |
int vis[maxn];//0 while,1 gray, 2 black | |
int fa[maxn]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
const int maxn = 1e5+7; | |
vector<int> ans, g[maxn]; | |
bool vis[maxn]; | |
void dfs(vector<int>p, int cur, int t) { | |
p.push_back(cur); | |
vis[cur] = 1; | |
if (cur == t) { | |
for (auto x:p) printf("%d ", x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. 二叉树第i层最多2^{i-1}个节点 | |
// 2. 深度为k的二叉树最多右2^k-1个节点 | |
// 3. 对于二叉树,设节点数为n, 有n0 + n1 + n2 = n; (*1) | |
// n = B + 1; // B 为分支数目 | |
// n = n1 + 2*n2 + 1; (*2) | |
// 结合(*1)、(*2) 有 n0 = n2 + 1; (*3) | |
// 如用二叉链表表示,空指针数为n+1, 由(*3)、(*1)易得2*n0 + n1 = n + 1; | |
// 4. 具有n个节点的完全二叉树的深度为floor(log_2n)+1 | |
#include <bits/stdc++.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
const int maxn = 1000+7; | |
/* 二叉树的三种遍历方式:preorder, inorder, postorder | |
* 左子树T1, 右子树T2, 根 r | |
* 题意:给出preorder和inorder,求postorder | |
* 思想:先根据先序遍历和中序遍历建二叉树树,然后求后序遍历即可, 注意若只给出前序和后序则是无法建树的 | |
* 9 | |
1 2 4 7 3 5 8 9 6 | |
4 7 2 1 8 5 9 3 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define pass // | |
struct node | |
{ | |
node *lc, *rc; | |
int key, color,height; | |
node(){} | |
node(int key):key(key){} | |
}*root; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
const int maxn = 1e5+7; | |
std::vector<int> g[maxn], ans; | |
bool vis[maxn]; | |
int indeg[maxn]; | |
int n,m; | |
void toposort() | |
{ | |
queue<int> q; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <time.h> | |
// 根据先序遍历判断是否是完全二叉树,输入-1表示null | |
struct TreeNode { | |
int ch; | |
struct TreeNode *left; | |
struct TreeNode *right; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Events" | |
-- 前提/premiss: | |
-- 1. 在iCloud云盘下新建Bear文件夹/Create a new folder "Bear" under the iCloud | |
-- 脚本做的事:/What the script does: | |
-- 1. 自动化点击/Automated click | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Plugin Manager | |
call plug#begin(expand('~/.vim/plugged')) | |
" 主题 | |
Plug 'arcticicestudio/nord-vim' | |
Plug 'tpope/vim-sensible' | |
Plug 'liuchengxu/space-vim-theme' | |
" 格式工具 | |
Plug 'Yggdroot/indentLine' " 缩进显示 | |
Plug 'scrooloose/nerdcommenter' " 注释工具 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
By default, when extracts the Xcode.zip, | |
macos will create tmp file in `/private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T/com.apple.AUHelperService`. | |
Sometimes, the /private has no ehough space to hold 19GB Xcode.app. | |
Thus we can create a soft link named `com.apple.AUHelperService` in the tmp dir. | |
Steps: | |
1. BACKUP `com.apple.AUHelperService` in `/private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T/` to `com.apple.AUHelperService_BACKUP` | |
2. mkdir named `com.apple.AUHelperService` wherever you have enough space, | |
3. ln -s /your/absolute/path/com.apple.AUHelperService /private/var/folders/v2/tbmrn60d2910x3w23ys5fgs00000gn/T | |
4. double click the Xcode.xip |
OlderNewer