PAT (Advanced Level) Practice
Chuyuan_li
这个作者很懒,什么都没留下…
展开
-
1071 Speech Patterns (25)
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...原创 2018-08-02 13:31:37 · 106 阅读 · 0 评论 -
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 15:53:43 · 133 阅读 · 0 评论 -
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 less than the node's key. The right su...原创 2018-08-13 15:55:06 · 336 阅读 · 1 评论 -
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 relation is defined to be t...原创 2018-08-16 15:09:34 · 109 阅读 · 0 评论 -
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 with followers relations. When a ...原创 2018-08-16 15:57:32 · 151 阅读 · 0 评论 -
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 must know immediately if we nee...原创 2018-08-16 17:00:33 · 104 阅读 · 0 评论 -
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 supposed to write a program to test...原创 2018-08-19 17:15:03 · 150 阅读 · 0 评论 -
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-22 21:07:59 · 167 阅读 · 0 评论 -
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 from the table and output the average sea...原创 2018-08-22 21:18:55 · 183 阅读 · 0 评论 -
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 less than the node's key. The right su...原创 2018-08-13 14:48:08 · 106 阅读 · 0 评论 -
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.InputEach input file contains one test case. Each case starts with a line...原创 2018-08-13 13:42:58 · 252 阅读 · 0 评论 -
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-08 16:02:03 · 367 阅读 · 0 评论 -
1022 Digital Library (30)
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 a...原创 2018-08-02 14:13:13 · 140 阅读 · 0 评论 -
1053 Path of Equal Weight (30)
Given a non-empty tree with root R, and with weight W~i~ assigned to each tree node T~i~. 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 ...原创 2018-08-11 16:10:19 · 98 阅读 · 0 评论 -
1079 Total Sales of 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-11 17:14:34 · 154 阅读 · 0 评论 -
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.Starting from one root supplier, everyone on th...原创 2018-08-11 17:39:29 · 108 阅读 · 0 评论 -
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 with the largest population.Input ...原创 2018-08-11 18:07:27 · 110 阅读 · 0 评论 -
1106 Lowest Price in Supply Chain
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 15:03:20 · 94 阅读 · 0 评论 -
1062 Talent and Virtue (25)
About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a man being outstanding in both talent and virt...原创 2018-08-03 10:21:42 · 86 阅读 · 0 评论 -
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-15 15:27:31 · 118 阅读 · 0 评论 -
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 in each city and the l...原创 2018-08-17 16:11:50 · 114 阅读 · 0 评论 -
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-17 17:42:13 · 169 阅读 · 0 评论 -
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 number of the postorder traversal se...原创 2018-08-30 17:00:08 · 232 阅读 · 0 评论 -
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 first obtain no less than 200 points from...原创 2018-08-30 05:37:23 · 202 阅读 · 0 评论 -
1126 Eulerian Path(25 分)
#include<cstdio>#include<fstream>#include<vector>using namespace std;const int maxn=510;vector<int> v[maxn];bool index[maxn]={false};int cnt=0;void dfs(int x){ inde...原创 2018-09-05 03:12:19 · 130 阅读 · 0 评论 -
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-09-05 05:16:39 · 256 阅读 · 0 评论 -
1120 Friend Numbers(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 and 51 are friend numbers since 1+2+3 = 5+1 = 6, and 6 is their ...原创 2018-09-05 18:32:02 · 133 阅读 · 0 评论 -
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-09-05 19:33:40 · 175 阅读 · 0 评论 -
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-09-05 20:52:32 · 190 阅读 · 0 评论 -
1116 Come on! Let's C(20 分)
"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny as...原创 2018-09-06 01:52:23 · 270 阅读 · 0 评论 -
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>0. Then N is palindromic if and only if ai=ak−i for...原创 2018-08-30 04:03:29 · 142 阅读 · 0 评论 -
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-09-02 00:51:08 · 397 阅读 · 0 评论 -
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 defined as a binary tree which has ...原创 2018-08-30 02:49:06 · 167 阅读 · 0 评论 -
1132 Cut Integer(20 分)
Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting...原创 2018-08-31 00:59:31 · 140 阅读 · 0 评论 -
1140 Look-and-say Sequence(20 分)
Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth n...原创 2018-08-28 17:41:10 · 183 阅读 · 0 评论 -
1141 PAT Ranking of Institutions(25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.Input Specification:Each input file conta...原创 2018-08-28 19:17:20 · 133 阅读 · 0 评论 -
1142 Maximal Clique(25 分)
A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adj...原创 2018-08-28 21:07:01 · 133 阅读 · 0 评论 -
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-31 20:52:02 · 158 阅读 · 0 评论 -
1134 Vertex Cover(25 分)
Each input file contains one test case. For each case, the first line gives two positive integers N and M (both no more than 104), being the total numbers of vertices and the edges, respectively. T...原创 2018-08-31 22:53:57 · 171 阅读 · 0 评论 -
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 queens share the same row, ...原创 2018-09-01 21:08:08 · 143 阅读 · 0 评论