![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT (Advanced Level)
Bonstoppo
逢山开路,遇水搭桥。以梦为马,不负韶华。
展开
-
PAT (Advanced Level) Practice
Advanced Level 题目的难度给我的感觉又不太一样。难度陡增,不仅仅是英语的题目,另外难度也上升了,也加入的算法的思想。原创 2018-08-18 16:55:36 · 517 阅读 · 1 评论 -
1094 The Largest Generation (25 point(s))
matter模板:DFS求每层深度code#include<iostream>#include<vector>using namespace std;vector<int> child[105];int level[105] = { 0 };int maxdepth = 0;void DFS(int root , int depth...原创 2019-08-25 22:05:49 · 133 阅读 · 0 评论 -
1058 A+B in Hogwarts (20 point(s))
1058.霍格沃兹的加法原创 2019-08-17 13:39:28 · 170 阅读 · 0 评论 -
1059 Prime Factors (25 point(s))
质因子分解原创 2019-08-18 13:22:23 · 157 阅读 · 0 评论 -
1015 Reversible Primes (20 point(s))
matter1.判断素数的时候注意三点:1.检查特判;2.sqr的转换因为sqrt需要是个float类型;3.循环之中需要对整除这种情况进行判断,所以需要有个等于。2.模板:进制转换模板//十进制转换其他进制while(N > 0){ d[len ++] = N % D; N /= D; }//radix D to 10 conversion for(int i...原创 2019-08-26 20:24:41 · 141 阅读 · 0 评论 -
1078 Hashing (25 point(s))
1078.哈希原创 2019-08-27 20:33:20 · 210 阅读 · 0 评论 -
1042 Shuffling Machine (20 point(s))
matter1.好蠢的输出。2.只是修改位置而不是修改整个的内容。对下标直接进行修改code#include<iostream>using namespace std;int main(){ int n , id[55] , start[55] , end[55]; scanf("%d" , &n); //intilization the id...原创 2019-08-27 22:01:26 · 138 阅读 · 0 评论 -
1019 General Palindromic Number (20 point(s))
matter判断回文和判断进制转换。code#include<iostream>#include<cstdio>#include<vector>using namespace std;bool judge(vector<int> v){ for(int i = 0 ; i <= v.size() / 2 ; i ++)...原创 2019-08-28 19:53:35 · 130 阅读 · 0 评论 -
1027 Colors in Mars (20 point(s))
matter这个地方注意其实本身只会有两位,所以只需要存一次即可。code#include<iostream>#include<cstdio>using namespace std;int main() { int a , b , c; char trans[14] = {'0' , '1' , '2' , '3' , '4' , '5' , '6...原创 2019-08-28 19:55:26 · 142 阅读 · 0 评论 -
1077 Kuchiguse (20 point(s))【未全对】
1077.Kuchiguse未全对,因为转换问题。原创 2019-08-30 20:37:48 · 152 阅读 · 0 评论 -
1062 Talent and Virtue (25 point(s))
1062.德才论原创 2019-08-31 19:48:59 · 129 阅读 · 0 评论 -
Bonstop算法模板(自创 + 整理)
目录图:DFSBFSDijkstra图:DFSconst int MAXV = 1000;const int INF = 1000000000;//邻接矩阵int n , G[MAXV][MAXV];bool vis[MAXV] = {false};void DFS(int u , depth){ vis[u] = true; for(int ...原创 2019-09-02 21:47:23 · 145 阅读 · 0 评论 -
1147 Heaps (30 分)
matter后面的难度绝对没有前面的难。前面有些题真的太难了。很多模拟都做不出来。1.给出一个层序遍历可以利用结点和其左右孩子的关系直接进行前中后序遍历。2.对于三位运算符的使用要多使用。code#include<iostream>#include<vector>using namespace std;const int MAXN = 1005;...原创 2019-09-06 21:57:22 · 121 阅读 · 0 评论 -
1149 Dangerous Goods Packaging (25 分)
matter纯粹的一道模拟题。code#include<iostream>#include<unordered_map>#include<vector>using namespace std;const int MAXN = 100000;int main(){ int n , m , l , a , b; unordered_ma...原创 2019-09-07 13:27:52 · 152 阅读 · 0 评论 -
1150 Travelling Salesman Problem (25 分)
matter1.freopen的使用。非常方便测试。2.逗号的使用也可以让代码简洁。code#include<iostream>#include<algorithm>#include<vector>using namespace std;const int MAXN = 205;const int INF = 10000000;in...原创 2019-09-07 21:40:28 · 133 阅读 · 0 评论 -
1079 Total Sales of Supply Chain (25 point(s))
matterDFS的作用:遍历整个树,求树的深度code#include<iostream>#include<vector>#include<cmath>using namespace std;const int MAXN = 100005;double P , R , ans;struct node{ int num; vec...原创 2019-08-25 21:40:16 · 91 阅读 · 0 评论 -
1090 Highest Price in Supply Chain (25 point(s))
matter不行以后都换成double类型的数据。。。2.模板:利用DFS求树的深度。code#include<iostream>#include<vector>#include<cmath>using namespace std;const int MAXN = 100010;vector<int> child[MAX...原创 2019-08-25 13:55:05 · 181 阅读 · 0 评论 -
1102 Invert a Binary Tree (25 point(s))
Matter很标准的一道题目,考察了前序遍历,后序遍历,层序遍历,可以作为一个模板使用。Code#include<iostream>#include<queue> #include<algorithm>using namespace std;const int MAXN = 15;int num = 0 , n;bool notroo...原创 2019-08-24 14:06:55 · 159 阅读 · 0 评论 -
【PAT】1154 Vertex Coloring
题目:Vertex Coloring (25 分)题目大意:判断图中同一条边的顶点的颜色是否一致的。如果没有一致的,则输出这个图里面有多少种颜色,反之,输出No。解题思路:1.保存数据:将数据利用一个结构体存起来。2.处理数据:利用color数组放每个点的颜色,利用set存放颜色。解题代码:#include<iostream>#include<vect...原创 2019-05-21 20:01:29 · 248 阅读 · 0 评论 -
1153 Decode Registration Card of PAT (25 point(s))
结构体排序 + map映射原创 2019-07-19 09:40:23 · 133 阅读 · 0 评论 -
DevC++使用技巧
目录1.解决无法编译器无法使用C++11的问题:1.解决无法编译器无法使用C++11的问题:打开【工具】->【编译选项】->【代码生成/优化】->【代码生成】->【语言生成(-std)】选择ISO C++11版本,点击确定。2.c_str()的问题:#include<iostream>#include<string.h>...原创 2019-07-17 20:32:53 · 2426 阅读 · 0 评论 -
1152 Google Recruitment (20 point(s))
切分找素数。原创 2019-07-17 21:29:10 · 165 阅读 · 0 评论 -
1006 Sign In and Sign Out (25 point(s))
判断大小原创 2019-08-03 19:00:56 · 236 阅读 · 0 评论 -
【PAT】2019,备战9月PAT
URL Answer Code Matter Degree 1006 Sign In and Sign Out (25 point(s)) 输入与输出 比较大小 Easy...原创 2019-08-03 19:12:32 · 335 阅读 · 0 评论 -
1011 World Cup Betting (20 point(s))
code:#include<iostream>using namespace std;int main(){ float a, sum = 1 ; int k; char S[3] = {'W' , 'T' , 'L'};//对应字符表// //输入// for(int i = 0 ; i < 3 ; i ++){ float max = -1.0 ...原创 2019-08-04 19:55:25 · 215 阅读 · 0 评论 -
1012 The Best Rank (25 point(s))
Matter:排名也会造成影响。期次在考场上的时候不要再去为了1,2分去浪费时间,跑出来成绩就可以了。AC:(柳诺)#include <cstdio>#include <algorithm>using namespace std;struct node { int id, best; int score[4], rank[4];}stu...原创 2019-08-05 23:14:45 · 146 阅读 · 0 评论 -
1050 String Subtraction (20 point(s))
Hash思想原创 2019-08-08 12:45:45 · 121 阅读 · 0 评论 -
1054 The Dominant Color (20 point(s))
matter:1.考察map的find函数的运用。2.考察map中的遍历,first,second的访问需要->。code:#include<iostream>#include<map>using namespace std;int main(){ int p , n , a; map<int , int> m;...原创 2019-08-13 13:23:38 · 123 阅读 · 0 评论 -
1055 The World's Richest (25 point(s))
Matter:1.搞懂了cmp的完全排序问题。2.根据输入的范围考虑问题。M的数值 < 100,这个地方如果不对100个人进行单独操作会超时。出现数据太多的时候就用空间换时间,将数据带出来,单独处理。Code:#include<iostream>#include<algorithm>#include<string.h>using n...原创 2019-08-13 19:32:49 · 158 阅读 · 0 评论 -
1046 Shortest Distance (20 point(s))
Matter:1.这个题目关键的地方在于D这个数组的设置。相当于是以1为开始的点。比如说2和5距离就是(5 - 1) - (2 - 1)的距离。2.swap可以直接使用,不必添加头文件。Code:#include<iostream>using namespace std;int main(){ int N , M, k , D[100005] , sum = ...原创 2019-08-07 20:47:31 · 153 阅读 · 0 评论 -
1051 Pop Sequence (25 point(s))
栈的模拟原创 2019-08-10 12:18:33 · 193 阅读 · 0 评论 -
1056 Mice and Rice (25 point(s))
1056.老鼠与大米原创 2019-08-14 22:53:41 · 179 阅读 · 0 评论 -
1052 Linked List Sorting (25 point(s))
链表排序原创 2019-08-11 13:49:17 · 117 阅读 · 0 评论 -
【408极简笔记】平衡二叉树
Q1:为什么要设置平衡二叉树?为了保证二叉搜索树的深度不会太深,出现”单边行情“。单边行情的意思就是只有一边,而另一边子树什么也没有。Q2:如何判定平衡还是不平衡?设置一个平衡因子。平衡因子 = 结点的左子树深度 - 右子树深度。规定平衡因子只能是 -1,0,1。Q3:如何插入使得二叉排序树可以平衡?整体思路:先插入,再调整。Step1:先按照二叉排序树的方式插入这个结点。...原创 2019-09-11 11:35:47 · 319 阅读 · 0 评论