![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT (Advanced Level)
julia7_
keep coding
展开
-
A1007 Maximum Subsequence Sum (25 分)(最大连续子序列和)(DP问题)
Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuous subsequen...原创 2019-02-27 16:26:23 · 148 阅读 · 0 评论 -
A1106 Lowest Price in Supply Chain (25 分)(与A1090相同)
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...原创 2019-02-24 17:16:33 · 129 阅读 · 0 评论 -
A1004 Counting Leaves (30 分)(类似题)(DFS)
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...原创 2019-02-24 18:09:28 · 130 阅读 · 0 评论 -
A1053 Path of Equal Weight (30 分)(树的DFS)
Given a non-empty tree with rootR, and with weightWiassigned to each tree nodeTi. Theweight of a path fromRtoLis defined to be the sum of the weights of all the nodes along the path fro...原创 2019-02-24 19:19:49 · 145 阅读 · 0 评论 -
A1040 Longest Symmetric String (25 分)(最长回文子串)(DP)
Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, givenIs PAT&TAP symmetric?, the longest symmetric sub-string iss PAT&TAP s, hence you ...原创 2019-02-28 18:33:10 · 139 阅读 · 0 评论 -
A1043 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...原创 2019-02-25 10:42:57 · 165 阅读 · 0 评论 -
A1064 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...原创 2019-02-25 11:03:36 · 649 阅读 · 0 评论 -
A1099 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...原创 2019-02-25 11:44:51 · 200 阅读 · 0 评论 -
A1066 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...原创 2019-02-25 12:14:36 · 902 阅读 · 0 评论 -
A1094 The Largest Generation (25 分)(求树的节点个数最多的一层节点个数)(DFS)
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 ...原创 2019-02-24 16:47:17 · 313 阅读 · 0 评论 -
A1079 Total Sales of Supply Chain (25 分)(树的DFS)(树的静态存储模板)
1079Total 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.Starti...原创 2019-02-23 21:47:35 · 194 阅读 · 0 评论 -
A1090 Highest Price in Supply Chain (25 分)(树的DFS)(树的静态存储)
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...原创 2019-02-23 21:16:08 · 179 阅读 · 0 评论 -
A1039 Course List for Student (25 分)(vector)
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 ...原创 2019-02-17 22:57:14 · 339 阅读 · 0 评论 -
A1045 Favorite Color Stripe (30 分)(最长不下降子序列问题)(DP)
Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts...原创 2019-02-27 17:45:41 · 197 阅读 · 0 评论 -
A1103 Integer Factorization (30 分)(将N表示为K个整数的P次方的和)(DFS)(难)
TheK−Pfactorization of a positive integerNis to writeNas the sum of theP-th power ofKpositive integers. You are supposed to write a program to find theK−Pfactorization ofNfor any positive...原创 2019-02-23 11:06:21 · 661 阅读 · 0 评论 -
A1047 Student List for Course (25 分)(vector + char二维数组)
本题为A1039 Course List for Student (25 分)反过来的题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 ...原创 2019-02-18 12:07:47 · 135 阅读 · 0 评论 -
A1020 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 traversal sequence of the cor...原创 2019-02-23 13:00:11 · 303 阅读 · 0 评论 -
1063 Set Similarity (25 分)(set)
Given two sets of integers, the similarity of the sets is defined to beNc/Nt×100%, whereNcis the number of distinct common numbers shared by the two sets, andNtis the total number of ...原创 2019-02-18 13:11:55 · 162 阅读 · 0 评论 -
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 from 1 to 6) is traversed, the stac...原创 2019-02-23 16:00:23 · 288 阅读 · 0 评论 -
A1102 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 fuck off.Now it's your turn to...原创 2019-02-23 18:19:56 · 290 阅读 · 0 评论 -
A1068 Find More Coins (30 分)(01背包问题)(难)
1068Find 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 o...原创 2019-03-01 12:08:03 · 314 阅读 · 0 评论 -
A1107 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. Asocial clusteris a set of people who have some of thei...原创 2019-02-25 17:44:44 · 161 阅读 · 0 评论 -
A1075 PAT Judge (25 分)(根据提交信息排序)(难)
Input Specification:每个输入文件包含一个测试用例。对于每种情况,第一行包含3个正整数,n(≤10^4) 用户总数,k(≤5)问题总数,m(≤10^5)提交的总数。然后假设用户ID是从00001到N的5位数字,问题ID是从1到K。下一行包含k个正整数p[i](i=1,…,k),其中p[i]对应第i个问题的满分。然后是M行,每个行以以下格式提供提交的信息:user_i...原创 2019-03-06 17:31:24 · 288 阅读 · 0 评论 -
A1080 Graduate Admission (30 分)(考生志愿与录取)(难)
It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission...原创 2019-03-06 19:06:32 · 190 阅读 · 0 评论 -
A1091 Acute Stroke (30 分)(三维图形)(BFS)(难)
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...原创 2019-03-09 15:04:03 · 117 阅读 · 0 评论 -
A1054 The Dominant Color (20 分)(水题)(map)
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the d...原创 2019-02-19 12:50:00 · 110 阅读 · 0 评论 -
B1039/A1092 到底买不买 (20 分)(哈希)
小红想买些珠子做一串自己喜欢的珠串。卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖。于是小红要你帮忙判断一下,某串珠子里是否包含了全部自己想要的珠子?如果是,那么告诉她有多少多余的珠子;如果不是,那么告诉她缺了多少珠子。为方便起见,我们用[0-9]、[a-z]、[A-Z]范围内的字符来表示颜色。例如在图1中,第3串是小红想做的珠串;那么第1串可以买,因为包含了全部她想要的珠子,...原创 2019-01-23 12:20:57 · 239 阅读 · 0 评论 -
A1033 To Fill or Not to Fill (25 分)(加油站问题)(贪心)(难)
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different ga...原创 2019-03-07 11:31:31 · 265 阅读 · 0 评论 -
A1010 Radix (25 分)(二分)(难)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer isyes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive inte...原创 2019-03-07 16:59:57 · 153 阅读 · 0 评论 -
A1057 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...原创 2019-03-11 13:14:55 · 522 阅读 · 0 评论 -
A1022 Digital Library (30 分)(map + set)
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...原创 2019-03-08 22:55:50 · 119 阅读 · 0 评论 -
A1016 Phone Bills (25 分)(计算话费)(排序)
A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When...原创 2019-03-06 15:20:31 · 307 阅读 · 0 评论 -
A1003 Emergency (25 分)(Dijsktra算法)(难)
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...原创 2019-02-26 17:44:17 · 235 阅读 · 0 评论 -
A1013 Battle Over Cities (25 分)(删除图的一个节点需要添加几条边连通)(图的DFS)(邻接表存储)
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...原创 2019-02-25 19:43:37 · 296 阅读 · 0 评论 -
A1021 Deepest Root (25 分)(选出使整棵树高度最大的树根节点)(图的DFS)
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 ...原创 2019-02-25 21:28:22 · 246 阅读 · 0 评论 -
A1071 Speech Patterns (25 分)(找出一句话中单词出现次数最多的那个)(map)
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...原创 2019-02-20 16:35:04 · 255 阅读 · 0 评论 -
A1051 Pop Sequence (25 分)(stack)
Given a stack which can keepMnumbers at most. PushNnumbers in the order of 1, 2, 3, ...,Nand pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of t...原创 2019-02-20 20:11:34 · 160 阅读 · 0 评论 -
A1034 Head of a Gang (30 分)(树的DFS)(邻接矩阵)(难)
One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call betweenAandB, we say thatAandBis related. The weight of a relation is defined to be t...原创 2019-02-26 12:54:25 · 234 阅读 · 0 评论 -
A1076 Forwards on Weibo (30 分)(L层之内的转发数)(图的BFS)
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 ...原创 2019-02-26 14:02:57 · 157 阅读 · 0 评论 -
A1082 Read Number in Chinese (25 分)(用拼音读数字)
Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. OutputFufirst if it is negative. For example, -123456789 is read asFu yi Yi er Qian san Bai ...原创 2019-03-05 20:13:33 · 329 阅读 · 0 评论