上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: #include<bits/stdc++.h> using namespace std; const int maxn = 500005; struct edge{ int next, to; }e[maxn << 1]; int head[maxn], cnt; int n, m, s, a, b, xx, yy; int depth[maxn], fa[maxn][22]; void add( 阅读全文
posted @ 2019-10-31 20:03 ATKevin 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 先注意初始化dp[], 后注意预处理dp[1]等 例如 acwing 1018最低通行费中没有初始化dp[][],和预处理dp[1][0],dp[0][1] 阅读全文
posted @ 2019-10-20 10:37 ATKevin 阅读(70) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/blog/content/32/ 1.n≤30, 指数级别, dfs+剪枝,状态压缩dp2.n≤100=> O(n^3), floyd(图论),dp3.n≤1000=> O(n^2),O(n ^2 logn), dp,二分4.n≤10000=> O(n 阅读全文
posted @ 2019-10-13 13:45 ATKevin 阅读(660) 评论(0) 推荐(0) 编辑
摘要: prim:给出一个无向图,求出最小生成树,如果该图不连通,则输出impossible。 #include<bits/stdc++.h>using namespace std;const int maxm = 200005;const int inf = 0x3f3f3f3f;struct edge{ 阅读全文
posted @ 2019-10-01 13:27 ATKevin 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 并查集 总结:1.求两次并查集可以用一个数组来使用, 一次并查集后更新fa[]数组即可; 2.求两个值的是否是一样的祖先时,用find(),不用fa[]数组判断,有可能其中某个值的路径没被压缩; 3.a,b公司都有可能是男或女 阅读全文
posted @ 2019-09-22 15:56 ATKevin 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 并查集 总结: 1.并查集板子掌握不熟练 阅读全文
posted @ 2019-09-14 18:46 ATKevin 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 并查集(路径压缩) // luogu p3367 并查集板子#include<bits/stdc++.h> using namespace std; int n, m, z, x, y; int f[10005]; int find(int x) { if(x == f[x]) return x; 阅读全文
posted @ 2019-09-12 19:34 ATKevin 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 总结:1.bfs的模板没有掌握好 2.string s 的时候可以用s[m]=x 将s字符串中的m位置的字符改变成x字符 一道简单的bfs 阅读全文
posted @ 2019-09-08 10:01 ATKevin 阅读(95) 评论(0) 推荐(0) 编辑
摘要: string https://blog.csdn.net/fdqw_sph/article/details/54233971 queue https://blog.csdn.net/zhongguozhichuang/article/details/53196415 阅读全文
posted @ 2019-08-22 21:38 ATKevin 阅读(68) 评论(0) 推荐(0) 编辑
摘要: void dfs() { if(到达中点状态) { ... //根据题意添加 return; } if(越界或不合法状态) return; if(特殊状态) // 剪枝 return; for(扩展方式) { if(扩张方式所到达状态合法) { 修改操作; // 根据题意添加 标记; dfs(); (还原标记); //是否加上还原标记根据题意 //如果加上还原标记就是回溯法 } } } 阅读全文
posted @ 2019-08-21 23:17 ATKevin 阅读(493) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 下一页