![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT (Advanced Level)
文章平均质量分 75
冷却明亮
这个作者很懒,什么都没留下…
展开
-
PAT (Advanced Level)-1144 The Missing Number
1144 The Missing Number(20 分)Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. ...原创 2018-08-18 23:13:05 · 98 阅读 · 0 评论 -
PAT (Advanced Level)-1112 Stucked Keyboard
1112 Stucked Keyboard(20 分)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 will ap...原创 2018-09-06 21:27:49 · 101 阅读 · 0 评论 -
PAT (Advanced Level)-1127 ZigZagging on a Tree(后序中序还原树)
1127 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 traversal se...原创 2018-09-10 16:39:01 · 189 阅读 · 0 评论 -
PAT (Advanced Level)-1149 Dangerous Goods Packaging
1149 Dangerous Goods Packaging(25 分)PAT (Basic Level)-1090 危险品装箱(25 分)When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we ...原创 2018-09-10 22:22:35 · 167 阅读 · 0 评论 -
PAT (Advanced Level)-1151 LCA in a Binary Tree (前中还原树LCA算法)
1151 LCA in a Binary Tree (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.Given any two nodes in a binary tree, you a...原创 2018-09-23 23:18:16 · 205 阅读 · 0 评论 -
PAT (Advanced Level)-1122 Hamiltonian Cycle
1122 Hamiltonian Cycle (25 分)The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a "Hamiltonian cycle".In this problem, you are sup...原创 2018-09-24 14:56:17 · 102 阅读 · 0 评论 -
PAT (Advanced Level)-1115 Counting Nodes in a BST
1115 Counting Nodes in a BST (30 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys le...原创 2018-10-01 13:56:48 · 107 阅读 · 0 评论 -
PAT (Advanced Level) -1123 Is It a Complete AVL Tree(层序遍历平衡二叉树)
1123 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 they ...原创 2018-10-01 15:02:40 · 281 阅读 · 0 评论 -
PAT (Advanced Level)-1118 Birds in Forest
1118 Birds in Forest (25 分)Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the...原创 2018-09-27 13:44:42 · 94 阅读 · 0 评论 -
PAT (Advanced Level)-1150 Travelling Salesman Problem
1150 Travelling Salesman Problem (25 分)The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest poss...原创 2018-09-23 00:24:44 · 119 阅读 · 0 评论 -
PAT (Advanced Level)-1111 Online Map(dijkstra+dfs)
1111 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 other...原创 2018-10-07 23:00:52 · 134 阅读 · 0 评论 -
PAT (Advanced Level)-1107 Social Clusters(并查集)
1107 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 set of...原创 2018-10-14 16:20:53 · 200 阅读 · 0 评论 -
PAT (Advanced Level)-1106 Lowest Price in Supply Chain
1106 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.Start...原创 2018-10-14 16:46:51 · 107 阅读 · 0 评论 -
PAT (Advanced Level)-1108 Finding Average(sscanf&sprintf)
PAT (Advanced Level)-1108 Finding Average (20 分)PAT (Basic Level)-1054. 求平均值(20 分)The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it com...原创 2018-09-29 16:14:32 · 145 阅读 · 0 评论 -
PAT (Advanced Level)-1114 Family Property(dfs连通域)
1114 Family Property (25 分)This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we ne...原创 2018-10-08 22:35:44 · 109 阅读 · 0 评论 -
PAT (Advanced Level) -1101 Quick Sort
1101 Quick Sort (25 分)PAT (Basic Level)-1045 快速排序 (25 分)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivo...原创 2018-10-17 14:39:22 · 137 阅读 · 0 评论 -
PAT (Advanced Level)-1100 Mars Numbers
PAT (Basic Level)-1044 火星数字 (20 分)1100 Mars Numbers (20 分)People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars. The numbers 1 to 12 on Earch is called "jan, fe...原创 2018-10-17 14:43:30 · 114 阅读 · 0 评论 -
PAT (Advanced Level) -1105 Spiral Matrix
1105 Spiral Matrix(25 分)PAT (Basic Level)-1050 螺旋矩阵(25 分)This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in ...原创 2018-09-06 16:45:48 · 122 阅读 · 0 评论 -
PAT (Advanced Level)-1120 Friend Numbers(20 分)
1120 Friend Numbers(20 分)PAT (Basic Level) -1064 朋友数(20 分)Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 an...原创 2018-09-04 00:04:56 · 74 阅读 · 0 评论 -
PAT (Advanced Level)-1148 Werewolf - Simple Version
1148 Werewolf - Simple Version(20 分)PAT (Basic Level)-1089 狼人杀-简单版(20 分)Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose ...原创 2018-09-11 17:17:08 · 208 阅读 · 0 评论 -
PAT (Advanced Level)-1143 Lowest Common Ancestor
1143 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 recursively ...原创 2018-08-26 15:15:43 · 138 阅读 · 0 评论 -
PAT (Advanced Level)-1136 A Delayed Palindrome
PAT (Basic Level)-1079延迟的回文数1136 A Delayed Palindrome(20 分)Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 with 0≤ai<10 for all i and ak...原创 2018-08-26 16:55:31 · 105 阅读 · 0 评论 -
PAT (Advanced Level) -1146 Topological Order
1146 Topological Order(25 分)This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are suppo...原创 2018-08-19 22:44:03 · 161 阅读 · 0 评论 -
PAT (Advanced Level)-1137 Final Grading
1080 MOOC期终成绩1137 Final Grading(25 分)For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must ...原创 2018-08-23 00:10:03 · 159 阅读 · 0 评论 -
PAT (Advanced Level)-1147 Heaps
1147 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 greater t...原创 2018-08-20 14:50:45 · 117 阅读 · 0 评论 -
PAT (Advanced Level) -1141 PAT Ranking of Institutions
1141 PAT Ranking of Institutions(25 分)PAT (Basic Level)-1085 PAT单位排行(25 分)每次 PAT 考试结束后,考试中心都会发布一个考生单位排行榜。本题就请你实现这个功能。输入格式:输入第一行给出一个正整数 N(≤105),即考生人数。随后 N 行,每行按下列格式给出一个考生的信息:准考证号 得分 学校其中...原创 2018-08-19 18:26:24 · 98 阅读 · 0 评论 -
PAT (Advanced Level)-1138 Postorder Traversal
1138 Postorder Traversal(25 分)Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first numb...原创 2018-08-23 14:32:52 · 154 阅读 · 0 评论 -
PAT (Advanced Level)-1145 Hashing - Average Search Time
1145 Hashing - Average Search Time(25 分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys...原创 2018-08-20 18:37:52 · 115 阅读 · 0 评论 -
PAT (Advanced Level)-1133 Splitting A Linked List
1133 Splitting A Linked List(25 分)PAT (Basic Level)-1075 链表元素分类Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-n...原创 2018-08-23 16:44:23 · 107 阅读 · 0 评论 -
PAT (Advanced Level) -1140 Look-and-say Sequence
PAT (Basic Level)1084 外观数列1140 Look-and-say Sequence(20 分) 1140 Look-and-say Sequence(20 分)Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213...原创 2018-08-20 21:55:36 · 94 阅读 · 0 评论 -
PAT (Advanced Level) -1124 Raffle for Weibo Followers
1124 Raffle for Weibo Followers(20 分)PAT (Basic Level) -1069 微博转发抽奖(20 分)John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he...原创 2018-08-31 15:53:37 · 93 阅读 · 0 评论 -
PAT (Advanced Level)-1125 Chain the Ropes
PAT (Basic Level) 1070 结绳(25 分)1125 Chain the Ropes(25 分)Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain th...原创 2018-08-31 16:21:29 · 173 阅读 · 0 评论 -
PAT (Advanced Level)-1139 First Contact
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 usually ...原创 2018-08-24 16:31:24 · 239 阅读 · 0 评论 -
PAT (Advanced Level) -1128 N Queens Puzzle
1128 N Queens Puzzle(20 分)The "eight queens puzzle" is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two...原创 2018-08-31 20:47:46 · 68 阅读 · 0 评论 -
PAT (Advanced Level)-1135 Is It A Red-Black Tree
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 black....原创 2018-08-24 22:57:39 · 169 阅读 · 0 评论 -
PAT (Advanced Level)-1130 Infix Expression
1130 Infix Expression(25 分)Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specifica...原创 2018-09-01 15:30:40 · 105 阅读 · 0 评论 -
PAT (Advanced Level)-1131 Subway Map(dfs)
1131 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 supposed ...原创 2018-09-04 16:10:43 · 114 阅读 · 0 评论 -
PAT (Advanced Level)-1102 Invert a Binary Tree
1102 Invert a Binary Tree (25 分)The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so ...原创 2018-10-17 17:03:05 · 116 阅读 · 0 评论