摘要: 按要求递归建树输出~ #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn=1014; struct node { int data; node * left; node 阅读全文
posted @ 2020-02-13 22:18 zlc0405 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 单向并查集,问至少给几个点可以遍历全图,连通块数量n,入度为0的点的数量m,取max(n,m)~ #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn=1e6+14; in 阅读全文
posted @ 2020-02-13 22:16 zlc0405 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 基础并查集~ #include<cstdio> #include<algorithm> #include<cstring> #include<unordered_map> #include<iostream> #include<string> using namespace std; const i 阅读全文
posted @ 2020-02-13 22:14 zlc0405 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 用并查集判断图是否连通,以及是否存在环~ #include<cstdio> #include<algorithm> #include<cstring> #include<vector> #include<unordered_map> using namespace std; const int ma 阅读全文
posted @ 2020-02-13 22:13 zlc0405 阅读(101) 评论(0) 推荐(0) 编辑
摘要: dfs判断图的连通块数量~ #include<cstdio> #include<algorithm> #include<vector> #include<cstring> using namespace std; const int maxn=1e6+14; vector<int> g[maxn]; 阅读全文
posted @ 2020-02-13 22:11 zlc0405 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 思维~ #include<bits/stdc++.h> using namespace std; const int maxn=1e6+14; int a[maxn]; int b[maxn]; int N; int main () { int T; scanf ("%d",&T); while ( 阅读全文
posted @ 2020-02-13 14:57 zlc0405 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 构造+思维~ #include<bits/stdc++.h> using namespace std; const int maxn=1e6+14; int N,M,T; int visit[maxn]; stack<int> st; vector<int> vi; int main () { vi 阅读全文
posted @ 2020-02-13 14:51 zlc0405 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 贪心~ #include<bits/stdc++.h> using namespace std; const int maxn=100014; int a[maxn]; int b[maxn]; int vis[maxn]; set<int>s; set<int>::iterator it; vec 阅读全文
posted @ 2020-02-13 14:37 zlc0405 阅读(269) 评论(0) 推荐(0) 编辑
摘要: krustral算法求最少结点数的最小生成树,用优先队列实时排序,优先选择已经被选中的中心~ #include<bits/stdc++.h> using namespace std; const int maxn=10014; int N,M,x,y; struct edge { string na 阅读全文
posted @ 2020-02-13 12:06 zlc0405 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 暴力搜索加剪枝~ #include<bits/stdc++.h> using namespace std; const int maxn=1014; int a[maxn]; bool visit[maxn]; vector<int> path,tmp; int N,M,L,cnt=0; void 阅读全文
posted @ 2020-02-13 12:04 zlc0405 阅读(230) 评论(0) 推荐(0) 编辑