自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

冷却明亮的博客

深渊与湖泊,树林和野草

  • 博客(43)
  • 收藏
  • 关注

原创 PAT (Advanced Level)-1102 Invert a Binary Tree

1102 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 ...

2018-10-17 17:03:05 117

原创 PAT (Advanced Level)-1100 Mars Numbers

PAT (Basic Level)-1044 火星数字 (20 分)1100 Mars Numbers (20 分)People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars. The numbers 1 to 12 on Earch is called "jan, fe...

2018-10-17 14:43:30 114

原创 PAT (Advanced Level) -1101 Quick Sort

1101 Quick Sort (25 分)PAT (Basic Level)-1045 快速排序 (25 分)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivo...

2018-10-17 14:39:22 139

原创 PAT (Advanced Level)-1106 Lowest Price in Supply Chain

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.Start...

2018-10-14 16:46:51 108

原创 PAT (Advanced Level)-1107 Social Clusters(并查集)

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...

2018-10-14 16:20:53 200

原创 PAT (Advanced Level)-1114 Family Property(dfs连通域)

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 ne...

2018-10-08 22:35:44 109

原创 PAT (Advanced Level)-1111 Online Map(dijkstra+dfs)

1111 Online Map (30 分)Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other...

2018-10-07 23:00:52 134

原创 PAT (Advanced Level) -1123 Is It a Complete AVL Tree(层序遍历平衡二叉树)

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 ...

2018-10-01 15:02:40 281

原创 PAT (Advanced Level)-1115 Counting Nodes in a BST

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 le...

2018-10-01 13:56:48 107

原创 PAT (Advanced Level)-1108 Finding Average(sscanf&sprintf)

PAT (Advanced Level)-1108 Finding Average (20 分)PAT (Basic Level)-1054. 求平均值(20 分)The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it com...

2018-09-29 16:14:32 145

原创 PAT (Advanced Level)-1118 Birds in Forest

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...

2018-09-27 13:44:42 94

原创 PAT (Advanced Level)-1122 Hamiltonian Cycle

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 sup...

2018-09-24 14:56:17 102

原创 PAT (Advanced Level)-1151 LCA in a Binary Tree (前中还原树LCA算法)

1151 LCA in a Binary Tree (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.Given any two nodes in a binary tree, you a...

2018-09-23 23:18:16 205

原创 PAT (Advanced Level)-1150 Travelling Salesman Problem

1150 Travelling Salesman Problem (25 分)The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest poss...

2018-09-23 00:24:44 119

原创 PAT (Advanced Level)-1148 Werewolf - Simple Version

1148 Werewolf - Simple Version(20 分)PAT (Basic Level)-1089 狼人杀-简单版(20 分)Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose ...

2018-09-11 17:17:08 208

原创 PAT (Advanced Level)-1149 Dangerous Goods Packaging

1149 Dangerous Goods Packaging(25 分)PAT (Basic Level)-1090 危险品装箱(25 分)When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we ...

2018-09-10 22:22:35 169

原创 PAT (Advanced Level)-1127 ZigZagging on a Tree(后序中序还原树)

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 se...

2018-09-10 16:39:01 189

原创 PAT (Advanced Level)-1112 Stucked Keyboard

1112 Stucked Keyboard(20 分)1112 Stucked Keyboard(20 分)On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will ap...

2018-09-06 21:27:49 101

原创 PAT (Advanced Level) -1105 Spiral Matrix

1105 Spiral Matrix(25 分)PAT (Basic Level)-1050 螺旋矩阵(25 分)This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in ...

2018-09-06 16:45:48 122

原创 PAT (Advanced Level)-1131 Subway Map(dfs)

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 ...

2018-09-04 16:10:43 114

原创 PAT (Advanced Level)-1120 Friend Numbers(20 分)

1120 Friend Numbers(20 分)PAT (Basic Level) -1064 朋友数(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 an...

2018-09-04 00:04:56 74

原创 PAT (Advanced Level)-1130 Infix Expression

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 Specifica...

2018-09-01 15:30:40 105

原创 PAT (Basic Level) -1068 万绿丛中一点红

1068 万绿丛中一点红(20 分)对于计算机而言,颜色不过是像素点对应的一个 24 位的数值。现给定一幅分辨率为 M×N 的画,要求你找出万绿丛中的一点红,即有独一无二颜色的那个像素点,并且该点的颜色与其周围 8 个相邻像素的颜色差充分大。输入格式:输入第一行给出三个正整数,分别是 M 和 N(≤ 1000),即图像的分辨率;以及 TOL,是所求像素点与相邻点的颜色差阈值,色差超过 ...

2018-08-31 22:12:43 68

原创 PAT (Advanced Level) -1128 N Queens Puzzle

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...

2018-08-31 20:47:46 68

原创 PAT (Advanced Level)-1125 Chain the Ropes

PAT (Basic Level) 1070 结绳(25 分)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 th...

2018-08-31 16:21:29 173

原创 PAT (Advanced Level) -1124 Raffle for Weibo Followers

1124 Raffle for Weibo Followers(20 分)PAT (Basic Level) -1069 微博转发抽奖(20 分)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...

2018-08-31 15:53:37 93

原创 PAT (Advanced Level)-1136 A Delayed Palindrome

PAT (Basic Level)-1079延迟的回文数1136 A Delayed Palindrome(20 分)Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ with 0≤a​i​​<10 for all i and a​k...

2018-08-26 16:55:31 106

原创 PAT (Basic Level) ー1081 检查密码

1081 检查密码(15 分)本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能。该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母、数字和小数点 .,还必须既有字母也有数字。输入格式:输入第一行给出一个正整数 N(≤ 100),随后 N 行,每行给出一个用户设置的密码,为不超过 80 个字符的非空字符串,以回车结束。输出格式:对每个用户的密码,在...

2018-08-26 16:16:21 107

原创 PAT (Advanced Level)-1143 Lowest Common Ancestor

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 ...

2018-08-26 15:15:43 138

原创 PAT (Advanced Level)-1135 Is It A Red-Black Tree

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....

2018-08-24 22:57:39 169

原创 PAT (Advanced Level)-1139 First Contact

1139 First Contact(30 分)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 ...

2018-08-24 16:31:24 239

原创 PAT (Advanced Level)-1133 Splitting A Linked List

1133 Splitting A Linked List(25 分)PAT (Basic Level)-1075 链表元素分类Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-n...

2018-08-23 16:44:23 107

原创 PAT (Advanced Level)-1138 Postorder Traversal

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 numb...

2018-08-23 14:32:52 154

原创 PAT (Advanced Level)-1137 Final Grading

1080 MOOC期终成绩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 ...

2018-08-23 00:10:03 159

原创 PAT (Basic Level)-1083 是否存在相等的差

1083 是否存在相等的差(20 分)给定 N 张卡片,正面分别写上 1、2、……、N,然后全部翻面,洗牌,在背面分别写上 1、2、……、N。将每张牌的正反两面数字相减(大减小),得到 N 个非负差值,其中是否存在相等的差?输入格式:输入第一行给出一个正整数 N(2 ≤ N ≤ 10 000),随后一行给出 1 到 N 的一个洗牌后的排列,第 i 个数表示正面写了 i 的那张卡片背面的...

2018-08-20 22:15:12 106

原创 PAT (Advanced Level) -1140 Look-and-say Sequence

PAT (Basic Level)1084 外观数列1140 Look-and-say Sequence(20 分) 1140 Look-and-say Sequence(20 分)Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213...

2018-08-20 21:55:36 94

原创 PAT (Advanced Level)-1145 Hashing - Average Search Time

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...

2018-08-20 18:37:52 115

原创 PAT (Advanced Level)-1147 Heaps

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 t...

2018-08-20 14:50:45 117

原创 PAT (Advanced Level) -1146 Topological Order

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 suppo...

2018-08-19 22:44:03 161

原创 PAT (Advanced Level) -1141 PAT Ranking of Institutions

1141 PAT Ranking of Institutions(25 分)PAT (Basic Level)-1085 PAT单位排行(25 分)每次 PAT 考试结束后,考试中心都会发布一个考生单位排行榜。本题就请你实现这个功能。输入格式:输入第一行给出一个正整数 N(≤10​5​​),即考生人数。随后 N 行,每行按下列格式给出一个考生的信息:准考证号 得分 学校其中...

2018-08-19 18:26:24 99

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除