上一页 1 ··· 51 52 53 54 55
摘要: 用并查集处理每个家庭的信息,注意标记~ #include<bits/stdc++.h> using namespace std; const int maxn=10010; bool visit[maxn]={false}; int N; struct node { int id; int chil 阅读全文
posted @ 2020-02-12 23:04 zlc0405 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 用并查集分割团伙,判断输出~ #include<bits/stdc++.h> using namespace std; const int maxn=10010; int father[maxn],isRoot[maxn]={0},weight[maxn]; unordered_map<string 阅读全文
posted @ 2020-02-12 23:03 zlc0405 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 利用树的前序和中序递归判定最小公共祖先~ 直接根据两个序列递归处理~ #include<bits/stdc++.h> using namespace std; const int maxn=10010; int N,M; int pre[maxn],in[maxn]; unordered_map<i 阅读全文
posted @ 2020-02-12 23:01 zlc0405 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 对于坐标平面的bfs模板题~ #include<bits/stdc++.h> using namespace std; const int maxn=1010; bool visit[1300][130][80]={false}; int adj[1300][130][80]; int n,m,l, 阅读全文
posted @ 2020-02-12 22:59 zlc0405 阅读(92) 评论(0) 推荐(0) 编辑
摘要: dfs,选择最优路径并输出~ 这道题难度非常炸裂,要求完完整整自己推一遍,DFS才算过关!思路:一遍dfs,过程中要维护两个变量,minCnt 中途停靠最少的站。minTransfer需要换成的最少次数1 可以这样算出一条线路的换乘次数:在line数组里保存每两个相邻站中间的线路是几号线,从头到尾遍 阅读全文
posted @ 2020-02-12 22:58 zlc0405 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 线性dfs,注意每次深搜完状态的维护~ #include<bits/stdc++.h> using namespace std; const int maxn=1010; vector<int> v,tmp,path; int n,k,p; void init () { int t=0,cnt=1; 阅读全文
posted @ 2020-02-12 22:56 zlc0405 阅读(128) 评论(0) 推荐(0) 编辑
摘要: floyd算法建立新图,dfs标记~ #include<bits/stdc++.h> using namespace std; const int maxn=1010; const int inf=1e9; int d[maxn][maxn]; vector<int> g[maxn]; bool v 阅读全文
posted @ 2020-02-12 22:41 zlc0405 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 直接暴力搜索即可~ #include<bits/stdc++.h> using namespace std; const int maxn=1014; char s[maxn][maxn]; int n,ans; int judge (int n,int m) { for (int i=n-1;i> 阅读全文
posted @ 2020-02-12 22:21 zlc0405 阅读(97) 评论(0) 推荐(0) 编辑
上一页 1 ··· 51 52 53 54 55