PTA甲级—STL使用】的更多相关文章

1051 Pop Sequence (25分) [stack] 简答的栈模拟题,只要把过程想清楚就能做出来. 扫描到某个元素时候,假如比栈顶元素还大,说明包括其本身的在内的数字都应该入栈.将栈顶元素和序列比对即可,相同则弹栈,继续扫描:否则无法生成满足条件的序列.注意栈满时不能入栈 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn =…
PTA甲级1094 The Largest Generation (25分) A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population. Input Specificatio…
目录 B1061 Dating (20分) 题目原文 Input Specification: Output Specification: Sample Input: Sample Output: 生词如下 题目大意 注意点: 总结和反思 B1061 Dating (20分) 首先,先贴柳神的博客 https://www.liuchuo.net/ 这是地址 想要刷好PTA,强烈推荐柳神的博客,和算法笔记 题目原文 Sherlock Holmes received a note with some…
https://pintia.cn/problem-sets/994805342720868352/problems/994805344776077312 其实这道题目不难,但是有很多坑点! 首先数据是性别+id,id不是数字! 输出的时候必须前面补0, 另外什么自己和自己连边,重复的边都要注意, 更注意的是 -0000,这个数据,不能用int来读,我艹 #include <iostream> #include <map> #include <algorithm> #i…
1032 Sharing (25分) 回顾了下链表的基本使用,这题就是判断两个链表是否有交叉点. 我最开始的做法就是用cnt[]记录每个节点的入度,发现入度为2的节点即为答案.后来发现这里忽略了两个链表初始节点都是一样的情况,于是这里cnt[]的含义变为每个节点被引用的次数,当一个节点被引用两次就说明被两个链表同时引用.此时又通过了部分测试样例,可是测试样例5始终通过不了.后来偶然翻到一篇博客才恍然大悟,这里的节点可能不止包含两个单词,即可能有多个起点表示多个单词,而题目只是问你给定的两个单词有…
1.简单数学 1008 Elevator (20分) 模拟题 #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <iostream> #include <map> #include <cmath> #define ll long long #define inf 0x3f3f3f using namesp…
散列 1078 Hashing (25 分) Quadratic probing (with positive increments only) is used to solve the collisions. 这句话说的是使用平方探测法来解决哈希冲突,Linear Probing(线性探测法).Quadratic probing(平方探测法)这种专业术语在平常的学习中应当认真记忆而不是认为不重要,因为这句话一开始看不懂,想当然认不重要就略过了,那结果多半WA. 知道了解决办法之后,需要处理的一…
题目链接 https://www.patest.cn/contests/pat-a-practise/1041 思路 可以用 map 标记 每个数字的出现次数 然后最后再 遍历一遍 找到那个 第一个 第一次出现的数字 AC代码 #include <cstdio> #include <cstring> #include <ctype.h> #include <cstdlib> #include <cmath> #include <climit…
题目链接 https://www.patest.cn/contests/pat-a-practise/1128 思路 可以 对每一个皇后 都判断一下 它的 行,列 ,左右对角线上 有没有皇后 深搜解决 但是这样太麻烦 其实我们可以想到 要符合要求的摆放 就是做到 每一行 每一列 每一条对角线 上 都是只有一个皇后的 每一行 就不用判断了 然后可以用 map 标记 该列 该对角线上 是否是已经有皇后的 如果已经有 那么就flag = 0 如果没有 就标记 然后 左对角线 上的特点就是 每个元素的…
此文章同步发布在我的CSDN上:https://blog.csdn.net/weixin_44385565/article/details/90041078   1112 Stucked Keyboard (20 分)   On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys wil…