PAT TOP Level题解
本专栏旨在提供PAT考试中的顶级题解,用C++完成,以供读者学习
Brielleqqqqqqjie
简单的事做到极致就是成功
展开
-
PAT顶级目录(C++)
标号 题目 题解 备注 1001 Battle Over Cities - Hard Version C++ 最小树生成算法(Kruskal) 1002 Business C++ 动态规划 1003 Universal Travel Sites C++ 最大流算法(Edmonds_Karp) 1004 T...原创 2019-12-06 21:37:31 · 1393 阅读 · 0 评论 -
1001 Battle Over Cities - Hard Version (35 分)(C++)
PAT顶级题解目录It is vitally important to have all the cities connected by highways in a war. If a city is conquered by the enemy, all the highways from/toward that city will be closed. To keep the...原创 2019-09-13 10:54:07 · 627 阅读 · 0 评论 -
1002 Business (35 分)(C++)
PAT顶级题解目录As the manager of your company, you have to carefully consider, for each project, the time taken to finish it, the deadline, and the profit you can gain, in order to decide if your g...原创 2019-09-14 13:33:55 · 999 阅读 · 0 评论 -
1003 Universal Travel Sites (35 分)(C++)
PAT顶级题解目录After finishing her tour around the Earth, CYLL is now planning a universal travel sites development project. After a careful investigation, she has a list of capacities of all the s...原创 2019-09-16 19:56:56 · 2119 阅读 · 0 评论 -
1004 To Buy or Not to Buy - Hard Version (35 分)(C++)
PAT顶级题解目录Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the s...原创 2019-11-29 22:40:07 · 732 阅读 · 0 评论 -
1005 Programming Pattern (35分)(C++)
Programmers often have a preference among program constructs. For example, some may preferif(0==a), while others may preferif(!a). Analyzing such patterns can help to narrow down a programmer's iden...原创 2020-02-02 08:32:08 · 968 阅读 · 0 评论 -
1007 Red-black Tree (35分)(C++)
There is a kind of binary tree namedred-black treein the data structure. It has the following 5 properties:(1) Every node is either red or black. (2) The root is black. (3) All the leaves are NU...原创 2020-02-05 21:08:15 · 1870 阅读 · 1 评论 -
1008 Airline Routes (35分)(C++)
Given a map of airline routes, you are supposed to check if a round trip can be planned between any pair of cities.Input Specification:Each input file contains one test case. For each case, the fi...原创 2019-12-21 20:10:23 · 773 阅读 · 0 评论 -
1009 Triple Inversions (35 分)(C++)
欢迎访问我的PAT顶级题解目录Given a list ofNintegersA1,A2,A3,...AN, there's a famous problem to count the number of inversions in it. An inversion is defined as a piar of indicesi<jsuch tha...原创 2019-11-25 12:17:29 · 698 阅读 · 0 评论 -
1010 Lehmer Code (35 分)(C++)
欢迎访问我的PAT顶级题解目录According to Wikipedia: "In mathematics and in particular in combinatorics, theLehmer codeis a particular way to encode each possible permutation of a sequence ofnnumbers." To be ...原创 2019-11-25 09:04:31 · 780 阅读 · 0 评论 -
1011 Cut Rectangles (35分)(C++)
When a rectangle is cut by a straight line, we can easily obtain two polygons as the result. But the reversed problem is harder: given two polygons, your task is to check whether or not they could ...原创 2020-02-11 22:09:21 · 837 阅读 · 0 评论 -
1013 Image Segmentation (35分)(C++)
Image segmentation is usually formulated as a graph partition problem, where each segment corresponds to a connected component. Moreover, each pixel is the vertex of the graph. Each edge has a weight,...原创 2020-02-03 12:34:49 · 763 阅读 · 0 评论 -
1014 Circles of Friends (35分)(C++)
A circle of friends is a network of friend relationships. If A is a friend of B, then B is considered a friend of A no matter B admits or not, and they are said to belong to the same circle. Here we a...原创 2019-12-17 21:28:49 · 816 阅读 · 1 评论 -
1015 Letter-moving Game (35 分)(C++)
PAT顶级题解目录Here is a simple intersting letter-moving game. The game starts with 2 strings S and T consist of lower case English letters. S and T contain the same letters but the orders might be...原创 2019-11-29 21:57:46 · 737 阅读 · 0 评论 -
1016 Uniqueness of MST (35 分)(C++)
PAT顶级题解目录Given any weighted undirected graph, there exists at least one minimum spanning tree (MST) if the graph is connected. Sometimes the MST may not be unique though. Here you are suppose...原创 2019-11-26 17:22:21 · 2801 阅读 · 0 评论 -
1017 The Best Peak Shape (35 分)(C++)
PAT顶级题解目录In many research areas, one important target of analyzing data is to find the best "peak shape" out of a huge amount of raw data full of noises. A "peak shape" of lengthLis an orde...原创 2019-11-12 09:16:16 · 461 阅读 · 0 评论 -
1018 Subnumbers (35 分)(C++)
PAT顶级题解目录Given a positive integerN, let us define asubnumberofNas a consecutive number of digitsNOT starting with 0. For example ifN=1021, it has 7 subnumbers, namely, 1, 10, 102, 1021...原创 2019-11-18 10:21:27 · 619 阅读 · 0 评论 -
1020 Delete At Most Two Characters (35 分)(C++)
PAT顶级题解目录Given a string which contains only lower case English letters, how many different strings you can get after deletingAT MOST TWOcharacters in it?Input Specification:Each input f...原创 2019-11-17 09:28:17 · 374 阅读 · 0 评论 -
1021 Safe Fruit (35 分)(C++)
PAT顶级题解目录There are a lot of tips telling us that some fruits must not be eaten with some other fruits, or we might get ourselves in serious trouble. For example, bananas can not be eaten with cantal...原创 2019-12-05 10:43:13 · 5340 阅读 · 1 评论 -
1022 Werewolf (35 分)(C++)
PAT顶级题解目录Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: "Player #2 is a werewolf....原创 2019-11-11 08:59:10 · 2439 阅读 · 0 评论 -
1024 Currency Exchange Centers (35分)(C++)
There are currently 168 internationally recognized unique national currencies in this world. But let us assume that we have business with other species in the entire universe... To change one currency...原创 2019-12-14 09:03:19 · 814 阅读 · 0 评论 -
1025 Keep at Most 100 Characters (35 分)(C++)
PAT顶级题解目录Given a string which contains only lower case letters, how many different non-empty strings you can get if you can keepAT MOST100 characters in the original order? (Note: The strin...原创 2019-10-30 21:01:01 · 478 阅读 · 0 评论 -
1026 String of Colorful Beads (35 分)(C++)
PAT顶级题解目录Eva would like to buy a string of beads with no repeated colors so she went to a small shop of which the owner had a very long string of beads. However the owner would only like to c...原创 2019-10-24 08:19:04 · 371 阅读 · 0 评论 -
1027 Larry and Inversions (35 分)(C++)
Larry just studied the algorithm to count number of inversions. He’s very interested in it. He’s considering another problem: Given a permutation of integers from 1 to n, how many inversions it has if...原创 2019-10-23 19:48:03 · 467 阅读 · 0 评论