摘要:
堆排序中,最主要的是这个down()函数 #include<iostream> using namespace std; const int N = 100010; int h[N], cnt; void down( int k ){ int t = k; if(k * 2 <= cnt && h[ 阅读全文
摘要:
#include<iostream> using namespace std; const int N = 100010; int p[N], siz[N]; int find(int k){ if(p[k] != k) p[k] = find(p[k]); return p[k]; } int m 阅读全文
摘要:
并查集,使用数组实现,find函数中使用了巧妙的递归 #include<iostream> using namespace std; const int N = 100010; int p[N]; int find(int k){ if(p[k] != k) p[k] = find(p[k]); r 阅读全文
摘要:
此题目使用Trie树,代码中的N代表着节点可能的最大个数。 #include<iostream> using namespace std; const int N = 3100010; int son[N][2], num[100010], idx; void insert(int k){ scan 阅读全文
摘要:
#include<iostream> using namespace std; const int N = 100010; int son[N][26], cnt[N], idx; char str[N]; void insert(char *str){ int p = 0; for(int i = 阅读全文