- 博客(36)
- 问答 (1)
- 收藏
- 关注
原创 PAT 1072 Gas Station(30 分)
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 hou...
2018-08-27 02:03:28 208
原创 PAT 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 decide the shortest path b...
2018-08-26 02:26:18 252
原创 PAT 1067 Sort with Swap(0, i)(25 分)
Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2...
2018-08-26 01:43:36 218
原创 PAT 1057 Stack(30 分)
Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the top position) and Po...
2018-08-25 02:01:34 142
原创 PAT 1068 Find More Coins(30 分)
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However,...
2018-08-24 00:47:46 189
原创 PAT 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 more than one, rebalancing is...
2018-08-24 00:28:05 151
原创 PAT 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 MRI slice, your job is to c...
2018-08-23 01:43:44 314
原创 PAT 1119 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 inorder traversal sequences, or preorder and inorder ...
2018-08-22 23:45:54 192
原创 PAT 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 differ by more than one, rebalancing is...
2018-08-22 01:54:09 155
原创 PAT 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 them into one piece, as shown by the figure. The resulting chai...
2018-08-21 01:17:02 178
原创 PAT 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 sequences. And it is a simple stand...
2018-08-21 00:46:40 220
原创 PAT 1129 Recommendation System(25 分)
Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that rates the user's preference by the number of time...
2018-08-20 02:31:17 302
原创 PAT 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 to help people with you...
2018-08-20 01:17:03 235
原创 PAT 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 Specification:Each input file contai...
2018-08-19 01:05:07 240
原创 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 black. (2) The root is black. (3) Every...
2018-08-19 00:34:15 171
原创 PAT 1133 Splitting A Linked List(25 分)
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea...
2018-08-18 01:21:56 166
原创 PAT 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 than or equal to (i...
2018-08-18 00:47:32 125
原创 PAT 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 scientists to count the maxi...
2018-08-16 01:05:37 222
原创 PAT 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 people who have some of thei...
2018-08-16 00:05:42 150
原创 PAT 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 supposed to tell if a given cycle ...
2018-08-15 01:54:57 302
原创 PAT 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 less than or equal to the node's key. ...
2018-08-14 00:47:49 148
原创 PAT 1134 Vertex Cover(25 分)
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if e...
2018-08-13 01:20:01 166
原创 PAT 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 less than the node's key.The right su...
2018-08-13 00:30:37 103
原创 PAT 1110 Complete Binary Tree(25 分)
Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N (≤20) wh...
2018-08-12 01:14:32 178
原创 PAT 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.Starting from one root supplier, everyone on th...
2018-08-12 00:08:46 227
原创 PAT 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 need to know the size of each f...
2018-08-11 00:32:44 235
原创 PAT 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 factorization of N for any positive...
2018-08-10 13:46:47 147
原创 PAT 1121 Damn Single(25 分)
"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of.Input Specification:Each inpu...
2018-08-10 00:23:51 126
原创 PAT 1108 Finding Average(20 分)
The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legalinput is a real ...
2018-08-09 09:52:19 143
原创 PAT 1113 Integer Set Partition(25 分)
Given a set of N (>1) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1 and n2 numbers, respectively. Let S1 and S2 denote the sums of a...
2018-08-09 00:11:08 137
原创 PAT 1126 Eulerian Path(25 分)
In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They were firs...
2018-08-08 00:35:04 134
原创 PAT 1098 Insertion or Heap Sort (25)
According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. At each iteration, insertion sort removes one element from the input da...
2018-08-06 15:54:24 95
原创 PAT 1089 Insert or Merge(25 分)
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,...
2018-08-06 15:14:44 129
原创 PAT 1087 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 most happiness.Input Specification:Each ...
2018-08-05 21:44:33 159
原创 PAT 1109 Group Photo(25 分)
Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest inte...
2018-08-03 21:24:24 396
原创 PAT 1101 Quick Sort (25)
There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its le...
2018-08-02 11:11:52 122
空空如也
VScode扩展宿主意外终止。
2017-12-02
TA创建的收藏夹 TA关注的收藏夹
TA关注的人