
pta题
文章平均质量分 65
Keep--Silent
这个作者很懒,什么都没留下…
展开
-
PAT (Advanced Level) Practice 1057 Stack
PAT (Advanced Level) Practice 1057 Stack树状数组查找中位数原创 2022-06-05 10:11:19 · 181 阅读 · 0 评论 -
深度优先搜索
深度优先搜索:Depth First Search本文讲解以DFS解决校选题深度优先搜索常常复杂度较大,所以需要根据题目的题意进行适当剪枝。目录中档题-2 勋总的幂集 (15 分)中档题-5 LIS (20 分)中档题-6 勋总的求偶日记 (25 分)压轴题-1 贝贝的数组划分 (30 分)压轴题-2 别装13 (30 分)中档题-2 勋总的幂集 (15 分)链接dfs:15分中档题-5 LIS (20 分)链接dfs:2分dfs剪枝后:8分中档题-6 勋总的求偶日记 (2原创 2021-11-20 12:45:45 · 763 阅读 · 0 评论 -
STL学习笔记(八)优先队列priority_queue
优先队列:priority_queue,在头文件#include里。优先队列的函数调用和普通队列一样。C++优先队列类似队列,但是在这个数据结构中的元素按照一定的断言排列有序。声明方式:priority_queue< type, container, function >priority_queue< type >//使用默认type的默认的比较函数排序使用优先队列的时候要定义优先队列的比较函数,或者使用默认的比较函数。函数:bool empty() const//返原创 2021-11-08 10:28:15 · 314 阅读 · 0 评论 -
STL学习笔记(六)vector与map的合用、vector与vector的合用
题目:21天梯国赛L2-37 335 28 74-1 -1 2228 74 35-1 -1 2211 66 035 28 7435 28 7443 35 28 742 -1 -1 221 11 66 01 28 74 35解决思路:记录:合用map与vector:map<vector<int>,int>q;第一关键字是向量vector,把每行的数列存入第二关键字是数量,记录每个数列的数量处理:用一个向量来存向量vector<v原创 2021-10-24 20:53:07 · 1226 阅读 · 0 评论 -
STL学习笔记(五)vector向量数组,创建与遍历树
vector向量数组,创建与遍历树题目背景说明代码及注释题目背景题目:列出叶结点对于给定的二叉树,本题要求你按从上到下、从左到右的顺序输出其所有叶节点。输入格式:首先第一行给出一个正整数 N(≤10),为树中结点总数。树中的结点从 0 到 N−1 编号。随后 N 行,每行给出一个对应结点左右孩子的编号。如果某个孩子不存在,则在对应位置给出 “-”。编号间以 1 个空格分隔。输出格式:在一行中按规定顺序输出叶节点的编号。编号间以 1 个空格分隔,行首尾不得有多余空格。输入样例:81 --原创 2021-10-17 22:40:13 · 338 阅读 · 0 评论 -
STL学习笔记(二)map
C++ Maps是一种关联式容器,包含“关键字/值”对map<容器1,容器2>,这里的容器可以是变量。如下校选题:题目大意:有n条聊天记录,找出发言最多的人(如果发言最多的不只一个人,找出发言最多的人中最早发言的那个)。如果不会map,思路:开一个很大的数组作为散列表写一个合理的哈希函数将字符串map思路:两个map容器: map<string,int>say; map<string,int>time;say[first]=second原创 2021-09-26 17:35:51 · 88 阅读 · 0 评论 -
1101 Quick Sort (25 分) st表
题目链接1101 Quick Sort (25 分)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its left and those larger than the原创 2021-09-09 10:04:21 · 114 阅读 · 0 评论 -
1068 Find More Coins (30 分)
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for eac原创 2021-09-06 10:41:01 · 287 阅读 · 0 评论 -
1010 Radix (25 分) 暴力枚举
1010 Radix (25 分)Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integers N1 and N2, your task is to find th原创 2021-09-06 10:15:47 · 190 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1049 Counting Ones (30 分)
The task is simple: given any positive integer N, you are supposed to count the total number of 1’s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1’s in 1, 10, 11, and 12.Input Specification:Each input fil原创 2021-08-22 14:25:31 · 97 阅读 · 0 评论 -
1045. Favorite Color Stripe (30)-PAT甲级真题
Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts together to form her favorite color stripe.It is said原创 2021-08-22 12:21:34 · 160 阅读 · 0 评论 -
vector向量数组,创建与遍历树
vector向量数组,创建与遍历树题目背景说明代码及注释题目背景题目:列出叶结点对于给定的二叉树,本题要求你按从上到下、从左到右的顺序输出其所有叶节点。输入格式:首先第一行给出一个正整数 N(≤10),为树中结点总数。树中的结点从 0 到 N−1 编号。随后 N 行,每行给出一个对应结点左右孩子的编号。如果某个孩子不存在,则在对应位置给出 “-”。编号间以 1 个空格分隔。输出格式:在一行中按规定顺序输出叶节点的编号。编号间以 1 个空格分隔,行首尾不得有多余空格。输入样例:81 --原创 2021-03-25 20:32:12 · 741 阅读 · 1 评论 -
队列
queue,一种先进先出的存储结构。类似于我们日常的排队,先排队的人先办理相关事务。First In ,First Out,简称FIFO。队列可以用数组实现也可以用链表实现。如果用链表实现的话,需要保存两个结点:表头,用于出队;表尾,用于入队。如果是用数组实现,需要两个变量记录头和尾,当这两个变量相遇时,队列为空。为了最大地利用空间,当这两个变量达到数组最大下表的时候,会走到0,这样形成了一个环,最大程度上利用了空间。然而,自己实现的队列,哪里有直接调用库函数里的函数来的轻松简单。在头文件#incl原创 2020-05-18 11:30:43 · 165 阅读 · 0 评论 -
4-4-堆 Windows消息队列 (25分)
消息队列是Windows系统的基础。对于每个进程,系统维护一个消息队列。如果在进程中有特定事件发生,如点击鼠标、文字改变等,系统将把这个消息加到队列当中。同时,如果队列不是空的,这一进程循环地从队列中按照优先级获取消息。请注意优先级值低意味着优先级高。请编辑程序模拟消息队列,将消息加到队列中以及从队列中获取消息。输入格式:输入首先给出正整数N(≤105 ),随后N行,每行给出一个指令——GET或PUT,分别表示从队列中取出消息或将消息添加到队列中。如果指令是PUT,后面就有一个消息名称、以及一个正原创 2020-05-18 10:54:54 · 281 阅读 · 0 评论