![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
考研算法PAT
Simod chen
这个作者很懒,什么都没留下…
展开
-
PAT 甲级 求二叉树最深的根
#include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; const int N = 10010, M = N * 2; int n; int h[N], e[M], ne[M], idx; //数组模拟邻接表 int p[N];//并查集用来表示父节点 int find(int x) { if(p[x.原创 2021-03-23 17:26:41 · 158 阅读 · 0 评论 -
PAT甲级 1020 树的遍历
针对该题主要就是考了对于中序遍历等三种遍历的熟悉程度,排序出来的分布规律,从上述图就可以看出一层的左子树和右子树的分布特点以及规律。 #include <iostream> #include <cstring> #include <algorithm> #include <unordered_map> using namespace std; const int N = 40; int n; int posterder[N], inorder[N]...原创 2021-03-22 20:35:03 · 150 阅读 · 0 评论 -
PAT 数叶子节点 (1004)
PAT 数叶子节点 (1004) #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 110; int n, m; int h[N], e[N], ne[N], idx;//该地方利用了数组模拟邻接表的原理来构造树,可以多查找相关的表示方法,网上有很多。 int cnt[N], max_depth; void add(int a原创 2021-03-20 15:17:37 · 126 阅读 · 0 评论 -
PAT 最佳排名
最佳排名 #include <iostream> #include <algorithm> #include <unordered_map> #include <vector> #include <cmath> using namespace std; unordered_map<string, vector<int>> grades;//明白hashmap的用法表示映射的相对关系,一个id //映射到那个同学的三科成原创 2021-03-18 17:01:01 · 110 阅读 · 0 评论