PAT
文章平均质量分 82
Jin_zc
专注于用最短的代码写题解
展开
-
拼题A (PTA) 公共题集题解收录
拼题A公共习题的题解收录原创 2023-01-27 17:08:54 · 5632 阅读 · 2 评论 -
Pintia(拼题A)刷题插件 on VS Code
用于 Pintia(PTA) 的刷题插件 on VS Code.原创 2022-08-06 18:39:55 · 13785 阅读 · 4 评论 -
7-46 新浪微博热门话题 (30分) (字符串解析)
PTA数据结构与算法题目集(中文): 7-46 新浪微博热门话题 (30分)新浪微博可以在发言中嵌入“话题”,即将发言中的话题文字写在一对“#”之间,就可以生成话题链接,点击链接可以看到有多少人在跟自己讨论相同或者相似的话题。新浪微博还会随时更新热门话题列表,并将最热门的话题放在醒目的位置推荐大家关注。本题目要求实现一个简化的热门话题推荐功能,从大量英文(因为中文分词处理比较麻烦)微博中解析出...原创 2020-03-30 17:16:56 · 1081 阅读 · 1 评论 -
PAT A1106 Lowest Price in Supply Chain (25分) (DFS+剪枝)
PAT甲级:A1106 Lowest Price in Supply Chain (25分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.S...原创 2020-03-29 09:18:11 · 166 阅读 · 0 评论 -
PAT A1091 Acute Stroke (30分) (BFS广度优先搜索)
PAT甲级:A1091 Acute Stroke (30分)One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in e...原创 2020-03-03 23:39:55 · 162 阅读 · 0 评论 -
PAT A1111 Online Map (30分) (Dijkstra最短路径算法)
PAT甲级:A1111 Online Map (30分)Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the ...原创 2020-03-02 22:14:27 · 263 阅读 · 0 评论 -
PAT A1095 Cars on Campus (30分) (模拟问题)
PAT甲级:A1095 Cars on Campus (30分)Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all...原创 2020-03-01 13:53:04 · 345 阅读 · 0 评论 -
PAT A1087 All Roads Lead to Rome (30分) (Dijkstra+DFS)
PAT甲级:A1087 All Roads Lead to Rome (30分)Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the mos...原创 2020-02-29 21:15:43 · 206 阅读 · 0 评论 -
PAT A1107 Social Clusters (30分) (并查集)
PAT甲级:A1107 Social Clusters (30分)When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A social cluster is a s...原创 2020-02-28 21:02:29 · 159 阅读 · 0 评论 -
PAT A1103 Integer Factorization (30分) (DFS+剪枝)
PAT甲级:A1103 Integer Factorization (30分)The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the...原创 2020-02-28 21:00:59 · 169 阅读 · 0 评论 -
PAT A1119 Pre- and Post-order Traversals (30分) (先序和后序序列建树)
PAT甲级:A1119 Pre- and Post-order Traversals (30分)Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inor...原创 2020-02-28 20:57:28 · 224 阅读 · 0 评论 -
PAT A1123 Is It a Complete AVL Tree (30分) (AVL树 和 CBT判定)
PAT甲级:A1123 Is It a Complete AVL Tree (30分)An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time ...原创 2020-02-26 17:45:28 · 322 阅读 · 0 评论 -
PAT A1127 ZigZagging on a Tree (30分) (不建树)
PAT甲级:A1127 ZigZagging on a Tree (30分)Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traver...原创 2020-02-25 23:22:09 · 173 阅读 · 0 评论 -
PAT A1131 Subway Map (30分) (DFS + 简单剪枝)
PAT甲级:A1131 Subway Map (30分)In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are sup...原创 2020-02-25 21:32:48 · 342 阅读 · 0 评论 -
PAT A1135 Is It A Red-Black Tree (30分) (DFS 红黑树的判定)
PAT甲级:1135 Is It A Red-Black Tree (30分)There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or b...原创 2020-02-24 18:01:15 · 256 阅读 · 0 评论 -
PAT A1139 First Contact (30分)
PAT甲级:1139 First Contact (30分)Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usu...原创 2020-02-24 18:00:41 · 396 阅读 · 0 评论 -
PAT A1143 Lowest Common Ancestor (30分) (平衡二叉树中的最低公共祖先)
PAT甲级:A1143 Lowest Common Ancestor (30分)The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursi...原创 2020-02-24 17:59:52 · 243 阅读 · 0 评论 -
PAT A1147 Heaps (30分) (堆的判定)
PAT甲级:A1147 Heaps (30分)In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either gre...原创 2020-02-24 17:59:02 · 173 阅读 · 0 评论 -
7-10 公路村村通 (30分) (最小生成树Prime与Kruskal算法)
PTA数据结构与算法题目集:7-10 公路村村通 (30分)现有村落间道路的统计数据表中,列出了有可能建设成标准公路的若干条道路的成本,求使每个村落都有公路连通所需要的最低成本。输入格式:输入数据包括城镇数目正整数N(≤1000)和候选道路数目M(≤3N);随后的M行对应M条道路,每行给出3个正整数,分别是该条道路直接连通的两个城镇的编号以及该道路改建的预算成本。为简单起见,城镇从1到N编号...原创 2020-02-24 00:47:36 · 1732 阅读 · 0 评论 -
7-14 电话聊天狂人 (25分)
PTA数据结构与算法题目集:7-14 电话聊天狂人 (25分)给定大量手机用户通话记录,找出其中通话次数最多的聊天狂人。输入格式:输入首先给出正整数N(≤105),为通话记录条数。随后N行,每行给出一条通话记录。简单起见,这里只列出拨出方和接收方的11位数字构成的手机号码,其中以空格分隔。输出格式:在一行中给出聊天狂人的手机号码及其通话次数,其间以空格分隔。如果这样的人不唯一,则输出狂人...原创 2020-02-24 00:46:16 · 1088 阅读 · 0 评论 -
【算法】堆栈模拟队列
相关题目: 7-22 堆栈模拟队列 (25分)将两个堆栈编号为s1、s2 (将容量较小的栈编号为 s1)用较小的栈作为临时存储栈(保证临时栈满时能完全移动到输出栈,即 s1 做临时栈)Push 操作,将元素压入 s1Pop 操作,在 s2 中取栈顶元素即临时栈负责进,输出栈负责出Push 操作若 s1 不满,则直接压入 s1若 s1 满且 s2 为空,则将 s1 中的元素...原创 2020-02-14 14:49:23 · 392 阅读 · 2 评论 -
7-7 六度空间 (30分) (BFS)
PTA数据结构与算法题目集:7-7 六度空间 (30分)“六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图1所示。“六度空间”理论虽然得到广泛的认同,并且正在得到越来越多的应用。但是数十年来,试图验证这个理论始终是许多...原创 2020-02-22 19:22:49 · 579 阅读 · 0 评论 -
7-21 求前缀表达式的值 (25分)
PTA数据结构与算法题目集:7-21 求前缀表达式的值 (25分)算术表达式有前缀表示法、中缀表示法和后缀表示法等形式。前缀表达式指二元运算符位于两个运算数之前,例如2+3*(7-4)+8/4的前缀表达式是:+ + 2 * 3 - 7 4 / 8 4。请设计程序计算前缀表达式的结果值。输入格式:输入在一行内给出不超过30个字符的前缀表达式,只包含+、-、*、/以及运算数,不同对象(运算数、运...原创 2020-02-22 19:21:48 · 1164 阅读 · 0 评论 -
PAT甲级 2019年春季考试(最简短的代码)
真题估计还得一年才能补充到PAT题库里,做题还需要去教育超市购买,坑呀!7-1 Sexy Primes (20分)Sexy primes are pairs of primes of the form (p, p+6), so-named since “sex” is the Latin word for “six”. (Quoted from http://mathworld.wolfram...原创 2020-02-21 18:45:05 · 412 阅读 · 0 评论 -
PAT A1053 Path of Equal Weight (30分) (DFS + 剪枝)
PAT甲级:A1053 Path of Equal Weight (30分)Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to L is defined to be the sum of the weights of...原创 2020-02-16 20:48:47 · 219 阅读 · 0 评论 -
PAT 1063 Set Similarity (25分) 使用set与map的超时问题
在 1063 Set Similarity (25分) 这道题目中,使用 unorderd_set 和 unordered_map 时出现超时问题,Given two sets of integers, the similarity of the sets is defined to be Nc/Nt ×100%, where Nc is the number of distinct commo...原创 2020-02-14 14:55:20 · 223 阅读 · 0 评论 -
PAT A1101 Quick Sort (动态规划)
A1101 Quick Sort | B1045 快速排序作者: CAO Peng, 单位: Google, 时间限制: 200 ms, 内存限制: 64 MBThere is a classical process named partition in the famous quick sort algorithm. In this process we typically choose ...原创 2020-02-14 14:40:36 · 158 阅读 · 0 评论 -
PAT A1025 PAT Ranking (25分)
PAT甲级:A1025 PAT Ranking (25 分)Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in seve...原创 2020-02-14 14:36:13 · 68 阅读 · 0 评论 -
PAT A1027 Colors in Mars (20分)
PAT甲级:A1027 Colors in Mars (20分)People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 dig...原创 2020-02-14 14:35:20 · 92 阅读 · 0 评论 -
PAT A1028 List Sorting (25分)
PAT甲级:A1028 List Sorting (25分)Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case...原创 2020-02-14 14:34:14 · 147 阅读 · 0 评论 -
PAT A1029 Median (25分)
PAT甲级:A1029 Median (25分)Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 =...原创 2020-02-14 14:33:16 · 104 阅读 · 0 评论 -
PAT A1030 Travel Plan (30分)
PAT甲级:A1030 Travel Plan (30分)A traveler’s map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler...原创 2020-02-14 14:31:04 · 133 阅读 · 0 评论