PAT Advanced
陈xLヾ
这个作者很懒,什么都没留下…
展开
-
PAT甲级1151~1155|C++实现
PAT甲级1151 LCA in a Binary Tree (30分)|C++实现PAT甲级1152 Google Recruitment (20分)|C++实现PAT甲级1153 Decode Registration Card of PAT (25分)|C++实现PAT甲级1154 Vertex Coloring (25分)|C++实现PAT甲级1155 Heap Paths (30分)|C++实现...原创 2020-10-16 23:58:28 · 164 阅读 · 0 评论 -
PAT甲级1155 Heap Paths (30分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N (1<N≤1,000), the number of keys in the tree. Then the next line contains N distinct integer keys (all in the range of int)原创 2020-10-16 23:57:05 · 642 阅读 · 0 评论 -
PAT甲级1154 Vertex Coloring (25分)|C++实现
一、题目描述原题链接A proper vertex coloring is a labeling of the graph’s vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at most k colors is called a (proper) k-coloring.Now you are supposed to tell if a原创 2020-10-16 23:48:05 · 186 阅读 · 0 评论 -
PAT甲级1153 Decode Registration Card of PAT (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:8 4B123180908127 99B102180908003 86A112180318002 98T107150310127 62A107180908108 100T123180908010 78B112160918035 88A107180908021 981 A2 1073 1809082 999Sample Output:C原创 2020-10-16 23:35:51 · 155 阅读 · 0 评论 -
PAT甲级1152 Google Recruitment (20分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. Each case first gives in a line two positive integers: L (≤ 1,000) and K (< 10), which are the numbers of digits of the given number and the prime to be found, respectively. Then原创 2020-10-16 23:07:01 · 1732 阅读 · 0 评论 -
PAT甲级1151 LCA in a Binary Tree (30分)|C++实现
一、题目描述原题链接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.Given any two nodes in a binary tree, you are supposed to find their LCA.Input Specification:Output Specification:S原创 2020-10-16 22:57:46 · 109 阅读 · 0 评论 -
PAT甲级1146~1150|C++实现
PAT甲级1146 Topological Order (25分)|C++实现PAT甲级1147 Heaps (30分)|C++实现PAT甲级1148 Werewolf - Simple Version (20分)|C++实现PAT甲级1149 Dangerous Goods Packaging (25分)|C++实现PAT甲级1150 Travelling Salesman Problem (25分)|C++实现...原创 2020-10-15 23:31:22 · 124 阅读 · 0 评论 -
PAT甲级1150 Travelling Salesman Problem (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:6 106 2 13 4 11 5 12 5 13 1 84 1 61 6 16 3 11 2 14 5 177 5 1 4 3 6 2 57 6 1 3 4 5 2 66 5 1 4 3 6 29 6 2 1 6 3 4 5 2 64 1 2 5 17 6 1 2 5 4 3 17 6 3 2 5 4 1 6Sample原创 2020-10-15 23:29:32 · 159 阅读 · 0 评论 -
PAT甲级1149 Dangerous Goods Packaging (25分)|C++实现
一、题目描述原题链接When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be packed with flammable liquid (易原创 2020-10-15 23:14:46 · 330 阅读 · 0 评论 -
PAT甲级1148 Werewolf - Simple Version (20分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input 1:5-2+3-4+5+4Sample Output 1:1 4Sample Input 2:6+6+3+1-5-2+4Sample Output 2(the solution is not unique):1 5Sample Input 3:5-2-3-4-5-1Sample Output 3:No Solu原创 2020-10-15 10:44:51 · 152 阅读 · 0 评论 -
PAT甲级1147 Heaps (30分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:3 898 72 86 60 65 12 23 508 38 25 58 52 82 70 6010 28 15 12 34 9 8 56Sample Output:Max Heap50 60 65 72 12 23 86 98Min Heap60 58 52 38 82 70 25 8Not Heap56 12 34 28 9 8 15 1原创 2020-10-15 10:30:01 · 127 阅读 · 0 评论 -
PAT甲级1146 Topological Order (25分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. For each case, the first line gives two positive integers N (≤ 1,000), the number of vertices in the graph, and M (≤ 10,000), the number of directed edges. Then M lines follow, each原创 2020-10-15 10:13:56 · 112 阅读 · 0 评论 -
PAT甲级1141~1145|C++实现
PAT甲级1141 PAT Ranking of Institutions (25分)|C++实现PAT甲级1142 Maximal Clique (25分)|C++实现PAT甲级1143 Lowest Common Ancestor (30分)|C++实现PAT甲级1144 The Missing Number (20分)|C++实现PAT甲级1145 Hashing - Average Search Time (25分)|C++实现...原创 2020-10-14 19:08:44 · 119 阅读 · 0 评论 -
PAT甲级1145 Hashing - Average Search Time (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:4 5 410 6 4 15 1111 4 15 2Sample Output:15 cannot be inserted.2.8二、解题思路考察了哈希表解决冲突的平方探测法,按照题目给的步骤进行模拟即可,代码比较易读,详情见代码注释。三、AC代码#include<iostream>#include<cstdio>#原创 2020-10-14 19:07:04 · 85 阅读 · 0 评论 -
PAT甲级1144 The Missing Number (20分)|C++实现
一、题目描述原题链接Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Output Specification:Print in a line the smallest positive integer that is missing from the input list.Sample Inpu原创 2020-10-14 18:56:59 · 97 阅读 · 0 评论 -
PAT甲级1143 Lowest Common Ancestor (30分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:6 86 3 1 2 5 4 8 72 58 71 912 -30 899 99Sample Output:LCA of 2 and 5 is 3.8 is an ancestor of 7.ERROR: 9 is not found.ERROR: 12 and -3 are not found.ERROR: 0 is not foun原创 2020-10-14 18:47:56 · 111 阅读 · 0 评论 -
PAT甲级1142 Maximal Clique (25分)|C++实现
一、题目描述原题链接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 adjacent vertex.(Quoted from https://en.wikipe原创 2020-10-14 18:26:04 · 105 阅读 · 0 评论 -
PAT甲级1141 PAT Ranking of Institutions (25分)|C++实现
一、题目描述原题链接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:Output Specification:Sample Input:10A57908 85 AuB57908 54 L原创 2020-10-14 18:14:50 · 120 阅读 · 0 评论 -
PAT甲级1136~1140|C++实现
PAT甲级1136 A Delayed Palindrome (20分)|C++实现PAT甲级1137 Final Grading (25分)|C++实现PAT甲级1138 Postorder Traversal (25分)|C++实现PAT甲级1139 First Contact (30分)|C++实现PAT甲级1140 Look-and-say Sequence (20分)|C++实现原创 2020-10-13 22:16:53 · 122 阅读 · 0 评论 -
PAT甲级1140 Look-and-say Sequence (20分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case, which gives D (in [0, 9]) and a positive integer N (≤ 40), separated by a space.Output Specification:Print in a line the Nth number in a look-and-say sequence of D.Sample Input:原创 2020-10-13 22:14:47 · 147 阅读 · 0 评论 -
PAT甲级1139 First Contact (30分)|C++实现
一、题目描述原题链接Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instead, he might ask ano原创 2020-10-13 13:03:37 · 562 阅读 · 0 评论 -
PAT甲级1138 Postorder Traversal (25分)|C++实现
一、题目描述原题链接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 sequence of the corresponding binary tree.Inp原创 2020-10-13 12:23:50 · 114 阅读 · 0 评论 -
PAT甲级1137 Final Grading (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:6 6 701234 880a1903 199ydjh2 200wehu8 300dx86w 220missing 400ydhfu77 99wehu8 55ydjh2 98dx86w 88a1903 8601234 39ydhfu77 88a1903 6601234 58wehu8 84ydjh2 82missing 99原创 2020-10-13 11:46:46 · 138 阅读 · 0 评论 -
PAT甲级1136 A Delayed Palindrome (20分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case which gives a positive integer no more than 1000 digits.Output Specification:Sample Input 1:97152Sample Output 1:97152 + 25179 = 122331122331 + 133221 = 255552255552 is a pa原创 2020-10-13 10:48:10 · 225 阅读 · 0 评论 -
PAT甲级1131~1135|C++实现
PAT甲级1131 Subway Map (30分)|C++实现PAT甲级1132 Cut Integer (20分)|C++实现PAT甲级1133 Splitting A Linked List (25分)|C++实现PAT甲级1134 Vertex Cover (25分)|C++实现PAT甲级1135 Is It A Red-Black Tree (30分)|C++实现原创 2020-10-12 23:13:23 · 128 阅读 · 0 评论 -
PAT甲级1135 Is It A Red-Black Tree (30分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:For each test case, print in a line “Yes” if the given tree is a red-black tree, or “No” if not.Sample Input:397 -2 1 5 -4 -11 8 14 -15911 -2 1 -7 5 -4 8 14 -15810 -7 5 -6 8 15 -11 17Sampl原创 2020-10-12 23:09:16 · 141 阅读 · 0 评论 -
PAT甲级1134 Vertex Cover (25分)|C++实现
一、题目描述原题链接Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Output Specification:Sample Input:10 118 76 84 58 48 11原创 2020-10-12 09:48:40 · 169 阅读 · 0 评论 -
PAT甲级1133 Splitting A Linked List (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:For each case, output in order (from beginning to the end of the list) the resulting linked list. Each node occupies a line, and is printed in the same format as in the input.Sample Input:00100 9原创 2020-10-12 09:33:48 · 108 阅读 · 0 评论 -
PAT甲级1132 Cut Integer (20分)|C++实现
一、题目描述原题链接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 to see that Z can be devided by the product原创 2020-10-12 09:15:54 · 92 阅读 · 0 评论 -
PAT甲级1131 Subway Map (30分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:47 1001 3212 1003 1204 1005 1306 77979 9988 2333 1204 2006 2005 2004 2003 2302 200113 3011 3812 3013 3001 1306 3003 2333 3066 3212 3008 2302 3010 30114 6666 8432 4011 130633011原创 2020-10-12 09:06:01 · 122 阅读 · 0 评论 -
PAT甲级1126~1130|C++实现
PAT甲级1126 Eulerian Path (25分)|C++实现PAT甲级1127 ZigZagging on a Tree (30分)|C++实现PAT甲级1128 N Queens Puzzle (20分)|C++实现PAT甲级1129 Recommendation System (25分)|C++实现PAT甲级1130 Infix Expression (25分)|C++实现原创 2020-10-09 23:50:20 · 1869 阅读 · 0 评论 -
PAT甲级1130 Infix Expression (25分)|C++实现
一、题目描述原题链接Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Output Specification:For each case, print in a line the infix ex原创 2020-10-09 23:48:33 · 218 阅读 · 0 评论 -
PAT甲级1129 Recommendation System (25分)|C++实现
一、题目描述原题链接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 times that an item has been accessed by this use原创 2020-10-09 23:34:33 · 154 阅读 · 0 评论 -
PAT甲级1128 N Queens Puzzle (20分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:For each configuration, if it is a solution to the N queens problem, print YES in a line; or NO if not.Sample Input:48 4 6 8 2 7 1 3 59 4 6 7 2 8 1 9 5 36 1 5 2 6 4 35 1 3 5 2 4Sample Output原创 2020-10-09 22:54:46 · 136 阅读 · 0 评论 -
PAT甲级1127 ZigZagging on a Tree (30分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N (≤30), the total number of nodes in the binary tree. The second line gives the inorder sequence and the third line gives the原创 2020-10-09 22:35:20 · 205 阅读 · 0 评论 -
PAT甲级1126 Eulerian Path (25分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. Each case starts with a line containing 2 numbers N (≤ 500), and M, which are the total number of vertices, and the number of edges, respectively. Then M lines follow, each describes原创 2020-10-09 22:08:31 · 181 阅读 · 0 评论 -
PAT甲级1121~1125|C++实现
PAT甲级1121 Damn Single (25分)|C++实现PAT甲级1122 Hamiltonian Cycle (25分)|C++实现(非原创)PAT甲级1123 Is It a Complete AVL Tree (30分)|C++实现PAT甲级1124 Raffle for Weibo Followers (20分)|C++实现PAT甲级1125 Chain the Ropes (25分)|C++实现...原创 2020-10-08 22:53:30 · 224 阅读 · 0 评论 -
PAT甲级1125 Chain the Ropes (25分)|C++实现
一、题目描述原题链接Input Specification:Output Specification:Sample Input:810 15 12 3 4 13 1 15Sample Output:14二、解题思路利用了贪心的思想,两条绳子要连起来,形成的新绳子的长度就是原来两段绳子之和的一半。现在给我们一些不同长度的绳子,要怎么样获得最长长度的绳子呢?考虑长度为1和15的两条绳子,得到的新绳子长度为8,那么与之前较长的绳子15的长度差就非常大,我们可以理解成绳子“损失”了,而原创 2020-10-08 22:46:35 · 152 阅读 · 0 评论 -
PAT甲级1124 Raffle for Weibo Followers (20分)|C++实现
一、题目描述原题链接John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo – that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him原创 2020-10-08 22:33:50 · 179 阅读 · 0 评论 -
(非原创)PAT甲级1123 Is It a Complete AVL Tree (30分)|C++实现
一、题目描述原题链接Input Specification:Each input file contains one test case. For each case, the first line contains a positive integer N (≤ 20). Then N distinct integer keys are given in the next line. All the numbers in a line are separated by a space.Out原创 2020-10-08 21:58:41 · 709 阅读 · 0 评论