
PAT
文章平均质量分 77
二脸
这个作者很懒,什么都没留下…
展开
-
pat1141 PAT Ranking of Institutions (排序)
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 contains one..原创 2022-03-03 23:31:01 · 114 阅读 · 0 评论 -
pat1133 Splitting A Linked List (静态链表 vector)
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 greater than K. The ord原创 2022-03-03 17:20:12 · 200 阅读 · 0 评论 -
a1138 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 number of the postorder traversal sequence of the correspon原创 2022-03-03 15:52:32 · 462 阅读 · 0 评论 -
a1127 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 sequences. And it is a simple standard routine to print t原创 2022-03-02 21:16:51 · 298 阅读 · 0 评论 -
a1121 Damn Single (set)
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 input file contains one tes..原创 2022-03-02 14:28:31 · 82 阅读 · 0 评论 -
a1120 Friend Numbers (set)
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 friend ID. Given some number原创 2022-03-02 13:00:08 · 103 阅读 · 0 评论 -
a1118 Birds in Forest(并查集,set)
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 scientists to count the maximum number of trees in the原创 2022-03-02 12:30:44 · 94 阅读 · 0 评论 -
a1117 Eddington Number
1117 Eddington Number (25 分)British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number",E-- that is, the maximum integerEsuch that it is forEdays that one rides more t...原创 2022-03-02 00:59:14 · 92 阅读 · 0 评论 -
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 less than or equal to the node's key. The right subtree o原创 2022-03-02 14:28:51 · 135 阅读 · 0 评论 -
1113 Integer Set Partition (sort排序)
1113 Integer Set Partition (25 分)Given a set ofN(>1) positive integers, you are supposed to partition them into two disjoint setsA1andA2ofn1andn2numbers, respectively. LetS1andS2denote the sums of all the numbers inA1...原创 2022-03-01 22:05:34 · 144 阅读 · 0 评论 -
a1111 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 is the fastest. It is guaranteed that a pat..原创 2022-03-01 21:13:47 · 181 阅读 · 0 评论 -
a1039 Course List for Student (map)
1039 Course List for Student (25 分)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 for a q..原创 2022-03-01 15:16:14 · 85 阅读 · 0 评论 -
a1036 Boys vs Girls
1036 Boys vs Girls (25 分)This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one test case. Each case contains原创 2022-03-01 15:09:00 · 92 阅读 · 0 评论 -
a1035 Password
1035 Password (20 分)To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish1(one) froml(Lin lowercase), or0(zero) fromO...原创 2022-03-01 12:09:25 · 72 阅读 · 0 评论 -
a1032 Sharing (静态链表)
1032 Sharing (25 分)To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,loadingandbeingare stored as sh...原创 2022-03-01 02:17:39 · 130 阅读 · 0 评论 -
a1030 Travel Plan (dijkstra + dfs)
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 between his/her starting city an原创 2022-03-01 01:49:33 · 178 阅读 · 0 评论 -
a1029 Median(vector的使用)
1029 Median (25 分)Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is 15. The median of two sequences is原创 2022-03-01 01:10:36 · 103 阅读 · 0 评论 -
1025 PAT Ranking (排序)
1025 PAT Ranking (25 分)Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately after原创 2022-03-01 00:57:43 · 132 阅读 · 0 评论 -
a1011 World Cup Betting (找最大值)
1011 World Cup Betting (20 分)With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting原创 2022-02-28 17:05:07 · 58 阅读 · 0 评论 -
a1008 Elevator
1008 Elevator (20 分)The highest building in our city has only one elevator. A request list is made up withNpositive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one f..原创 2022-02-28 16:30:38 · 102 阅读 · 0 评论 -
a1006 Sign In and Sign Out (时间换算)
1006 Sign In and Sign Out (25 分)At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you are supposed to find原创 2022-02-28 16:11:37 · 151 阅读 · 0 评论 -
a1005 Spell It Right (string应用)
1005 Spell It Right (20 分)Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Each case occupies one line whi原创 2022-02-28 15:55:58 · 93 阅读 · 0 评论 -
a1004 Counting Leaves (DFS)
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.Input Specification:Each input file contains one test case. Each case starts with a line containing0&l.原创 2022-02-28 15:42:06 · 105 阅读 · 0 评论 -
a1003 Emergency (dijkstra + dfs)
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 length of each road between any pa原创 2022-02-28 15:40:12 · 124 阅读 · 0 评论 -
a1076 Forwards on Weibo (DFS、BFS)
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 user makes a post on Weib原创 2022-02-27 20:53:57 · 116 阅读 · 0 评论 -
a1021 Deepest Root (图的遍历、DFS)
1021 Deepest Root (25 分)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 is calledthe deepest root.I.原创 2022-02-27 15:56:24 · 214 阅读 · 0 评论 -
a1013 Battle Over Cities (图的遍历 DFS)
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 need to repair any other hi原创 2022-02-27 14:41:17 · 178 阅读 · 0 评论 -
1076 Forwards on Weibo(BFS)
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 user makes a post on Weib原创 2022-02-26 20:38:51 · 265 阅读 · 0 评论 -
a1034 Head of a Gang (DFS、并查集)
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 betweenAandB, we say thatAandBis related. The weight of a relation is defined to be the total time length of all ...原创 2022-02-26 18:59:47 · 192 阅读 · 0 评论 -
pat1107 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. Asocial clusteris a set of people who have some of their hobbies in common. You ar..原创 2022-02-26 13:11:05 · 106 阅读 · 0 评论 -
1099 Build A Binary Search Tree(树的遍历)
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 subtree of a node原创 2022-02-25 23:53:24 · 487 阅读 · 0 评论 -
pat1064 Complete Binary Search Tree(树的遍历)
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 subtree of a n...原创 2022-02-25 22:48:00 · 188 阅读 · 0 评论 -
pat1053Path of Equal Weight (DFS)
1053 Path of Equal Weight (30 分)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 fromRto any leaf nodeL.N...原创 2022-02-25 19:12:52 · 212 阅读 · 0 评论 -
pat1094 The Largest Generation (DFS、BFS)
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 Specification:Each原创 2022-02-25 16:40:20 · 150 阅读 · 0 评论 -
pat1106 Lowest Price in Supply Chain (DFS)
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.Starting from one root supplier, everyone on the chain buys p原创 2022-02-25 15:18:09 · 84 阅读 · 0 评论 -
pat1079 Total Sales of Supply Chain (DFS)
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 the chain buys pr原创 2022-02-25 14:30:48 · 87 阅读 · 0 评论 -
pat1090 Highest Price in Supply Chain (DFS)
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 the chain buys原创 2022-02-25 13:59:47 · 99 阅读 · 0 评论 -
pat甲级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 fuck off.Now it's your turn to prove that YOU CAN ..原创 2022-02-25 11:34:50 · 300 阅读 · 0 评论 -
pat1086 Tree Traversals Again(树的遍历)
初始版本:不知道最后一个测试点为什么一直段错误#include <iostream>#include "stack"#include "algorithm"#include "vector"using namespace std;int n;int pre[30],in[30];vector<int> post;void postOrder(int preL,int preR,int inL,int inR){ if (inL > inR) r原创 2022-02-25 00:49:45 · 195 阅读 · 0 评论 -
pat甲级1020 Tree traversals (后序+中序 ->层序)
第一次做不出来,学习了柳神的解法pre函数的参数 root:根节点在后序中的位置;start:子树在中序中开始位置序号;end:子树在中序中结束的位置序号index:从0开始,每个节点的序号左边是2*index+1,右边是2*index;层序遍历即可按照index从小到大的顺序输出#include <iostream>#include "map"#include "vector"#include "algorithm"using namespace std;ve.原创 2022-02-24 22:34:03 · 513 阅读 · 0 评论