![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT (Advanced Level) Practice
文章平均质量分 77
摩天佳迪斯
不是你死就是我生
展开
-
1087 All Roads Lead to Rome (30 point(s))
1087 All Roads Lead to Rome (30 point(s))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 most happiness.Input Specification:Each input file conta原创 2021-03-06 22:56:29 · 122 阅读 · 0 评论 -
1072 Gas Station (30 point(s))
1072 Gas Station (30 point(s))A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service ra原创 2021-03-06 20:00:35 · 99 阅读 · 0 评论 -
1030 Travel Plan (30 point(s))
1030 Travel Plan (30 point(s))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 decide the shortest path between his/her starting c原创 2021-03-05 21:19:55 · 118 阅读 · 0 评论 -
1018 Public Bike Management (30 point(s))
1018 Public Bike Management (30 point(s))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 return it to any other stations in the city.The Publ原创 2021-03-04 22:45:29 · 92 阅读 · 1 评论 -
1003 Emergency (25 point(s))
1003 Emergency (25 point(s))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 in each city and the length of each road between原创 2021-03-03 18:30:03 · 107 阅读 · 1 评论 -
1076 Forwards on Weibo (30 point(s))
1076 Forwards on Weibo (30 point(s))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 with followers relations. When a user makes a post o原创 2021-03-02 21:43:28 · 47 阅读 · 0 评论 -
1034 Head of a Gang (30 point(s))
1034 Head of a Gang (30 point(s))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 relation is defined to be the total time length o原创 2021-03-02 16:43:17 · 97 阅读 · 0 评论 -
1021 Deepest Root (25 point(s))
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 highest tree. Such a root is called the deepest root.Input Specification:Each in原创 2021-03-01 21:30:10 · 83 阅读 · 0 评论 -
1013 Battle Over Cities (25 point(s))
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 must know immediately if we need to repair any other highways to keep the rest of the c原创 2021-03-01 16:47:46 · 77 阅读 · 1 评论 -
1098 Insertion or Heap Sort (25 point(s))
1098 Insertion or Heap Sort (25 point(s))According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the loca原创 2021-02-28 22:48:14 · 55 阅读 · 0 评论 -
1107 Social Clusters (30 point(s))
1107 Social Clusters (30 point(s))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 people who have some of their hobbies in common.原创 2021-02-28 20:48:32 · 68 阅读 · 0 评论 -
1066 Root of AVL Tree (25 point(s))
1066 Root of AVL Tree (25 point(s))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 more than one, rebalancing is done to restore thi原创 2021-02-28 19:26:03 · 74 阅读 · 0 评论 -
1099 Build A Binary Search Tree (30 point(s))
1099 Build A Binary Search Tree (30 point(s))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 less than the node’s key.The right subtree of a n原创 2021-02-28 16:55:46 · 92 阅读 · 0 评论 -
1064 Complete Binary Search Tree (30 point(s))
1064 Complete Binary Search Tree (30 point(s))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 less than the node’s key.The right subtree of a原创 2021-02-28 16:31:05 · 63 阅读 · 0 评论 -
1053 Path of Equal Weight (30point(s))
1053 Path of Equal Weight (30point(s))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 all the nodes along the path from R to any原创 2021-01-11 00:05:28 · 78 阅读 · 0 评论 -
1004 Counting Leaves (30point(s))
1004 Counting Leaves (30point(s))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 test case. Each case starts with a line containing原创 2021-01-10 22:59:24 · 87 阅读 · 0 评论 -
1094 The Largest Generation (25point(s))
1094 The Largest Generation (25point(s))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 Specification:E原创 2021-01-10 22:23:22 · 82 阅读 · 0 评论 -
1106 Lowest Price in Supply Chain (25point(s))
1106 Lowest Price in Supply Chain (25point(s))A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain bu原创 2021-01-10 21:55:35 · 88 阅读 · 0 评论 -
1079 Total Sales of Supply Chain (25point(s))
1079 Total Sales of Supply Chain (25point(s))A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buy原创 2021-01-10 21:18:33 · 105 阅读 · 0 评论 -
1090 Highest Price in Supply Chain (25point(s))
1090 Highest Price in Supply Chain (25point(s))A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain b原创 2021-01-10 20:48:39 · 88 阅读 · 0 评论 -
1102 Invert a Binary Tree (25point(s))
1102 Invert a Binary Tree (25point(s))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 fuck off.Now it’s your turn to prove that YOU CAN i原创 2021-01-09 17:50:32 · 84 阅读 · 0 评论 -
1086 Tree Traversals Again (25point(s))
1086 Tree Traversals Again (25point(s))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 from 1 to 6) is traversed, the stack operations are原创 2021-01-01 23:03:32 · 62 阅读 · 0 评论 -
1020 Tree Traversals (25point(s))
1020 Tree Traversals (25point(s))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 traversal sequence of the corresponding binary tree原创 2021-01-01 22:33:06 · 83 阅读 · 0 评论 -
1091 Acute Stroke (30point(s))
1091 Acute Stroke (30point(s))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 MRI slice, your job is to calculate the volume of th原创 2021-01-01 21:20:17 · 65 阅读 · 0 评论 -
1103 Integer Factorization (30point(s))
1103 Integer Factorization (30point(s))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 factorization of N for any positive integers N, K a原创 2021-01-01 19:43:41 · 74 阅读 · 0 评论 -
1050 螺旋矩阵 (25point(s))
1050 螺旋矩阵 (25point(s))本题要求将给定的 N 个正整数按非递增的顺序,填入“螺旋矩阵”。所谓“螺旋矩阵”,是指从左上角第 1 个格子开始,按顺时针螺旋方向填充。要求矩阵的规模为 m 行 n 列,满足条件:m×n 等于 N;m≥n;且 m−n 取所有可能值中的最小值。输入格式:输入在第 1 行中给出一个正整数 N,第 2 行给出 N 个待填充的正整数。所有数字不超过 104 ,相邻数字以空格分隔。输出格式:输出螺旋矩阵。每行 n 个数字,共 m 行。相邻数字以 1 个空原创 2020-12-30 22:51:50 · 68 阅读 · 0 评论 -
1024 Palindromic Number (25point(s))
1024 Palindromic Number (25point(s))A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Non-palindromic n原创 2020-12-30 21:29:44 · 127 阅读 · 0 评论 -
1023 Have Fun with Numbers (20point(s))
1023 Have Fun with Numbers (20point(s))Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number consisting exactly原创 2020-12-30 21:00:43 · 65 阅读 · 0 评论 -
1097 Deduplication on a Linked List (25point(s))
1097 Deduplication on a Linked List (25point(s))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, only the first node of which the value or absolute原创 2020-12-28 21:33:09 · 54 阅读 · 0 评论 -
1056 Mice and Rice (25point(s))
1056 Mice and Rice (25point(s))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 mouse is to eat as much rice as possible in order to原创 2020-12-28 19:37:06 · 58 阅读 · 0 评论 -
1051 Pop Sequence (25point(s))
1051 Pop Sequence (25point(s))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 possible pop sequence of the stack. For example, if M原创 2020-12-27 22:24:57 · 72 阅读 · 0 评论 -
1022 Digital Library (30point(s))
1022 Digital Library (30point(s))A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Given any qu原创 2020-12-27 21:48:36 · 79 阅读 · 0 评论 -
1071 Speech Patterns (25point(s))
1071 Speech Patterns (25point(s))People often have a preference among synonyms of the same word. For example, some may prefer “the police”, while others may prefer “the cops”. Analyzing such patterns can help to narrow down a speaker’s identity, which is原创 2020-12-27 20:59:19 · 57 阅读 · 0 评论 -
1100 Mars Numbers (20point(s))
1100 Mars Numbers (20point(s))People on Mars count their numbers with base 13:Zero on Earth is called “tret” on Mars.The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, respectively.For the next原创 2020-12-26 19:56:10 · 54 阅读 · 0 评论 -
1060 Are They Equal (25point(s))
1060 Are They Equal (25point(s))If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×105 with simple chopping. Now given the number of significant digits on a ma原创 2020-12-26 19:07:44 · 50 阅读 · 0 评论 -
1063 Set Similarity (25point(s))
1063 Set Similarity (25point(s))Given two sets of integers, the similarity of the sets is defined to be Nc /Nt ×100%, where Nc is the number of distinct common numbers shared by the two sets, and Nt is the total number of distinct nu原创 2020-12-26 18:30:24 · 79 阅读 · 0 评论 -
1047 Student List for Course (25point(s))
1047 Student List for Course (25point(s))Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input Specification:E原创 2020-12-25 22:40:43 · 65 阅读 · 0 评论 -
1039 Course List for Student (25point(s))
1039 Course List for Student (25point(s))Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query.I原创 2020-12-25 22:14:23 · 68 阅读 · 0 评论 -
1096 Consecutive Factors (20point(s))
1096 Consecutive Factors (20point(s))Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three consecutive numbers. Now given any positive N, yo原创 2020-12-25 21:41:32 · 58 阅读 · 0 评论 -
1059 Prime Factors (25point(s))
1059 Prime Factors (25point(s))Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1k1 ×p2k2 ×⋯×pmkm .Input Specification:Each input file contain原创 2020-12-25 20:59:42 · 65 阅读 · 0 评论