PAT
PAT刷题总结
就是爱喝百香果冷饮
这个作者很懒,什么都没留下…
展开
-
1018 Public Bike Management
1018 Public Bike Management (30 分)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and retu...原创 2019-04-24 21:26:50 · 206 阅读 · 3 评论 -
1030 Travel Plan
1030 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 to de...原创 2019-04-23 21:03:24 · 127 阅读 · 0 评论 -
1003 Emergency
1003 Emergency (25 分)As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams ...原创 2019-04-22 21:36:45 · 116 阅读 · 0 评论 -
最短路径Dijkstra
Dijkstra算法Dijkstra算法用来解决单源最短路径问题,即给定图G和起点S,通过算法得到S到达其他每个顶点的最短距离。Dijkstra的基本思想是对图G(V,E)设置集合S,存放已被访问的顶点,然后每次从集合V-S中选择与起点S的最短距离最小的一个顶点(记为u),访问并加入集合S。之后,令顶点u为中介点,优化起点S与所有从u能到...原创 2019-04-22 21:28:17 · 152 阅读 · 0 评论 -
1021 Deepest Root
1021 Deepest Root (25 分)A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a h...原创 2019-04-20 10:34:47 · 60 阅读 · 0 评论 -
1074 Reversing Linked List
1074 Reversing Linked List (25 分)Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then yo...原创 2019-03-02 23:11:12 · 348 阅读 · 0 评论 -
1097 Deduplication on a Linked List
1097 Deduplication on a Linked List (25 分)Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, ...原创 2019-03-04 16:51:35 · 75 阅读 · 0 评论 -
1103 Integer Factorization
1103 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 K−P f...原创 2019-03-05 17:07:11 · 228 阅读 · 0 评论 -
1091 Acute Stroke (30 分)
1091 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 each MR...原创 2019-03-11 16:31:30 · 135 阅读 · 0 评论 -
1020 Tree Traversals
1020 Tree Traversals (25 分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order t...原创 2019-03-14 15:52:51 · 77 阅读 · 0 评论 -
1086 Tree Traversals Again
1086 Tree Traversals Again (25 分)An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered f...原创 2019-03-14 17:31:56 · 86 阅读 · 0 评论 -
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 fu...原创 2019-03-15 15:19:57 · 63 阅读 · 0 评论 -
1053 Path of Equal Weight
1053 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 weig...原创 2019-03-18 19:17:24 · 97 阅读 · 0 评论 -
1090 Highest Price in Supply Chain
1090 Highest 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.Starti...原创 2019-03-19 17:52:58 · 68 阅读 · 0 评论 -
1094 The Largest Generation
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 w...原创 2019-03-27 23:19:34 · 181 阅读 · 0 评论 -
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.Startin...原创 2019-03-28 00:36:20 · 69 阅读 · 0 评论 -
1004 Counting Leaves
1004 Counting Leaves (30 分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one t...原创 2019-03-29 14:18:21 · 196 阅读 · 0 评论 -
1043 Is It a Binary Search Tree
1043 Is It a Binary Search Tree (25 分)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 l...原创 2019-03-30 17:48:07 · 82 阅读 · 1 评论 -
1066 Root of AVL Tree
1066 Root of AVL Tree (25 分)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 differ by ...原创 2019-04-05 18:25:22 · 132 阅读 · 0 评论 -
1064 Complete Binary Search Tree
1064 Complete Binary Search Tree (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 ...原创 2019-04-06 16:10:53 · 80 阅读 · 0 评论 -
1099 Build A Binary Search Tree
1099 Build A Binary Search Tree (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 l...原创 2019-04-06 17:26:52 · 108 阅读 · 0 评论 -
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 ...原创 2019-04-07 16:12:21 · 172 阅读 · 0 评论 -
1034 Head of a Gang
1034 Head of a Gang (30 分)One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a ...原创 2019-04-15 21:05:02 · 76 阅读 · 0 评论 -
1052 Linked List Sorting
1052 Linked List Sorting (25 分)A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer...原创 2019-03-01 16:17:18 · 83 阅读 · 0 评论 -
1032 Sharing
1032 Sharing (25 分)To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same ...原创 2019-02-28 21:10:39 · 178 阅读 · 0 评论 -
1056 Mice and Rice
1056 Mice and Rice (25 分)Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mo...原创 2019-02-26 22:27:23 · 91 阅读 · 0 评论 -
1051 Pop Sequence
1051 Pop Sequence (25 分)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a pos...原创 2019-02-25 22:36:50 · 162 阅读 · 0 评论 -
1076 Forwards on Weibo
1076 Forwards on Weibo (30 分)Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed wit...原创 2019-04-16 20:41:34 · 143 阅读 · 0 评论 -
1013 Battle Over Cities
1013 Battle Over Cities (25 分)It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We ...原创 2019-04-18 20:37:12 · 107 阅读 · 0 评论