摘要: 按要求递归建树输出~ #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) 编辑
摘要: 暴力搜索加剪枝~ 看的人好多...更新一下: 这道题的正解应该是求最大团之类的...暴力搜索是拿不到分的,我用了好几种奇怪的技巧用爆搜卡掉了。。。 #include<bits/stdc++.h> using namespace std; const int maxn=1014; const int 阅读全文
posted @ 2020-02-13 12:03 zlc0405 阅读(640) 评论(0) 推荐(0) 编辑
摘要: 暴力搜索加剪枝,二进制保存状态,set去重~ #include<bits/stdc++.h> using namespace std; const int maxn=7; string s[maxn]; struct node { int x,y; }Node[100]; int N,M,K,H; 阅读全文
posted @ 2020-02-13 12:02 zlc0405 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 动态规划找最长上升子序列,正反遍历一遍序列即可~ #include<bits/stdc++.h> using namespace std; const int maxn=10010; int N; int a[maxn]; int l[maxn]; int r[maxn]; int main () 阅读全文
posted @ 2020-02-13 12:01 zlc0405 阅读(144) 评论(0) 推荐(0) 编辑
摘要: dfs判断连通块的数量,prim算法建立最小生成树并判断是否唯一~ #include<bits/stdc++.h> using namespace std; const int maxn=1014; const int inf=1e9; int g[maxn][maxn]; int d[maxn]; 阅读全文
posted @ 2020-02-13 11:40 zlc0405 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 双下标法找最长公共子序列(不能删除字符) #include<bits/stdc++.h> using namespace std; const int maxn=1014; string s; string t; int main () { cin>>s>>t; int maxLength=0; i 阅读全文
posted @ 2020-02-13 11:38 zlc0405 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 大水题,dfs判连通块的数量,bfs每个点找朋友圈的最大直径~ #include<bits/stdc++.h> using namespace std; const int maxn=1014; vector<int> g[maxn]; bool visit[maxn]; int N; int ma 阅读全文
posted @ 2020-02-13 11:37 zlc0405 阅读(150) 评论(0) 推荐(0) 编辑
摘要: krustral算法加并查集,按题给要求维护并查集~ #include<bits/stdc++.h> using namespace std; const int maxn=1014; const int inf=1e9; int N,M,x,y; int c,w; struct edge { in 阅读全文
posted @ 2020-02-13 11:35 zlc0405 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 直接暴力枚举,注意每次深搜完状态的还原~ #include<bits/stdc++.h> using namespace std; const int maxn=1014; int visit[maxn][maxn]; int N,M,x,y; int cnt; int maxcnt; int X[ 阅读全文
posted @ 2020-02-13 11:33 zlc0405 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 大模拟题,按要求建立多边形,先定位斜边的位置,再分类讨论~ #include<bits/stdc++.h> using namespace std; const int maxn=1014; struct node { double x,y; }Node[2][maxn]; double dista 阅读全文
posted @ 2020-02-13 11:32 zlc0405 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 跟1009几乎是同一道题~ #include<bits/stdc++.h> using namespace std; const int maxn=1e6+14; int a[maxn]; int c[maxn*8]; int r[maxn]; int lowbit (int x) { return 阅读全文
posted @ 2020-02-13 11:30 zlc0405 阅读(132) 评论(0) 推荐(0) 编辑