随笔分类 -  基础算法刷题记录

摘要:基本思想: 有一个大坑,就是字典序的问题; 还有一个就是代码简洁度的问题; 关键点: 无; #include<iostream> #include<vector> #include<string> using namespace std; const int maxn = 30; int p, q; 阅读全文
posted @ 2020-03-08 21:26 暮云林凌 阅读(130) 评论(0) 推荐(0)
摘要:基本思想: 还是卡在了建模上,个人觉得BFS一定要注意一下方面: 1.状态,一定要找一个可以拓展的状态,可以进行迭代; 2.边界,例如本题,如果使用广搜,就是取模为0,如果使用深搜,就是没有溢出,longlong最多为19位; 但是这个题目还有有一个疑点,就是内存超限问题; 看到两百位自己想到了大数 阅读全文
posted @ 2020-03-08 19:51 暮云林凌 阅读(129) 评论(0) 推荐(0)
摘要:基本思想: 第一次见到这种抽象形式的搜索问题,其实看相关参考问题豁然开朗,就是三维和二维遍历的一个变种,没有什么不同的; 自己当时首先卡在了以下几个点上: 1.用BFS还是DFS? 显然用不了DFS,其一代价太大,不确定因素太多;其二不能保证边界到达时是最优的; 2.怎么保证边界最优? 答案是设定一 阅读全文
posted @ 2020-03-08 18:06 暮云林凌 阅读(208) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<vector> #include<string> using namespace std; int charge(string a, string b) { int cnt=0; for (int i = 0; 阅读全文
posted @ 2020-03-07 01:20 暮云林凌 阅读(262) 评论(0) 推荐(0)
摘要:基本思想: 快速幂的拓展,把快速幂乘法的指数部分改成矩阵即可; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<map> #include<set> using namespace std; const in 阅读全文
posted @ 2020-03-06 12:18 暮云林凌 阅读(236) 评论(0) 推荐(0)
摘要:基本思想: 只关注了入度和联通问题,没有关注到两个用例点: 1.这个题目空树也算树; 2.一个节点的时候,自环不构成树; 所以一个树的定义: 树内除了根节点一个结点入度为0,其他所有入度都为1; 关键点: 抓住定义; #include<iostream> #include<string> #incl 阅读全文
posted @ 2020-03-06 01:32 暮云林凌 阅读(193) 评论(0) 推荐(0)
摘要:关键思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<map> using namespace std; const int maxn = 1020; int father[maxn]; int 阅读全文
posted @ 2020-03-06 00:47 暮云林凌 阅读(164) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<map> using namespace std; const int maxn = 1020; int father[maxn]; int 阅读全文
posted @ 2020-03-06 00:43 暮云林凌 阅读(155) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<map> using namespace std; int main() { string s; while (cin>>s){ map<st 阅读全文
posted @ 2020-03-05 21:26 暮云林凌 阅读(138) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<map> using namespace std; int main() { int n; string s; map<string, str 阅读全文
posted @ 2020-03-05 21:16 暮云林凌 阅读(121) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<map> using namespace std; const int maxn = 2000; struct node { string n 阅读全文
posted @ 2020-03-05 20:59 暮云林凌 阅读(318) 评论(0) 推荐(0)
摘要:基本思想: 启发的点有两个: 1.对于取余判断,直接判断最后一位即可; 2.对于二进制转十进制,可以每次加和一位乘2; 关键点: 无; #include<iostream> #include<string> #include<vector> using namespace std; string d 阅读全文
posted @ 2020-03-05 20:48 暮云林凌 阅读(179) 评论(0) 推荐(0)
摘要:基本思想: 注意一下,1000的阶乘在2000位数字以上,之前西交考察过类似的脑筋急转弯题目; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; 阅读全文
posted @ 2020-03-05 10:58 暮云林凌 阅读(168) 评论(0) 推荐(0)
摘要:基本思路: 详见机试题目总结专栏; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; const int maxn = 1000; struct 阅读全文
posted @ 2020-03-05 10:47 暮云林凌 阅读(195) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<stdio.h> #include<stdlib.h> #include<iostream> #include<string> #include<vector> #include<algorithm> #include<map> #include< 阅读全文
posted @ 2020-03-04 23:58 暮云林凌 阅读(154) 评论(0) 推荐(0)
摘要:基本思想: 注意建树的引用问题; 要么return node* 要么node* &root 关键点: 无; #include<stdio.h> #include<stdlib.h> #include<iostream> #include<string> #include<vector> #inclu 阅读全文
posted @ 2020-03-04 23:43 暮云林凌 阅读(249) 评论(0) 推荐(0)
摘要:基本思想: 要求用两个序列构建新的二叉树,标准写法,注意下; 关键点: 无; #include<stdio.h> #include<stdlib.h> #include<iostream> #include<string> #include<vector> #include<algorithm> # 阅读全文
posted @ 2020-03-04 23:26 暮云林凌 阅读(142) 评论(0) 推荐(0)
摘要:基本思想: 根据完整的遍历序列进行生成二叉树,其中空节点置空处理使得构建成为可能,不再需要两个序列同时决定; 关键点: 注意构建的问题; #include<stdio.h> #include<stdlib.h> #include<iostream> #include<string> #include 阅读全文
posted @ 2020-03-04 16:29 暮云林凌 阅读(189) 评论(0) 推荐(0)
摘要:基本思想: 直接打表; 关键点: 无; #include<stdio.h> #include<stdlib.h> #include<iostream> #include<string> #include<vector> #include<algorithm> #include<map> #inclu 阅读全文
posted @ 2020-03-04 11:19 暮云林凌 阅读(191) 评论(0) 推荐(0)
摘要:基本思想: 不用打表,直接判断; 关键点: 无; #include<stdio.h> #include<stdlib.h> #include<iostream> #include<string> #include<vector> #include<algorithm> #include<map> # 阅读全文
posted @ 2020-03-04 11:11 暮云林凌 阅读(198) 评论(0) 推荐(0)