
PAT
DedicateToAI
这个作者很懒,什么都没留下…
展开
-
2019.12.7PAT冬季考试第四题 - 7-4 Cartesian Tree (30分)
ACartesian treeis a binary tree constructed from a sequence of distinct numbers. The tree is heap-ordered, and an inorder traversal returns the original sequence. For example, given the sequence { 8...原创 2020-01-01 22:58:06 · 348 阅读 · 0 评论 -
2019.12.7PAT冬季考试第二题 - 7-3 Summit (25分)
7-3Summit(25分)Asummit(峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so...原创 2020-01-01 22:37:51 · 546 阅读 · 0 评论 -
2019.12.7PAT冬季考试第二题 - 7-2 Block Reversing (25分)
Given a singly linked listL. Let us consider everyKnodes as ablock(if there are less thanKnodes at the end of the list, the rest of the nodes are still considered as a block). Your job is to re...原创 2020-01-01 22:16:58 · 309 阅读 · 0 评论 -
2019.12.7PAT冬季考试第一题 - 7-1 Good in C (20分)
第一题7-1Good in C(20分)When your interviewer asks you to write "Hello World" using C, can you do as the following figure shows?Input Specification:Each input file contains one test case. For ...原创 2020-01-01 22:01:19 · 327 阅读 · 0 评论 -
总结与反思 - 12月7日冬季PAT甲级考试
第一次参加PAT甲级考试,地点在上海大学计算中心。首先要说下这个位置,地图上没有明显的标识,准考证上也没有明确的写,最后是靠自己问路问来的。上海大学计算中心:首先找到图书馆附近,然后找D楼,D楼的4楼就是计算中心啦。然后说下环境,机房是比较老的了,不过看上去编译环境还是比较齐全的,python, java, c都有,因为自己之前一直是用的VS2019,这次也打开了vs2010,然后就被坑...原创 2019-12-12 11:25:04 · 325 阅读 · 0 评论 -
PAT甲级简单题最后冲刺
A1001Calculatea+band output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Input Specification:Eac...原创 2019-12-07 00:03:16 · 455 阅读 · 0 评论 -
PAT甲级 - 1018 Public Bike Management (30分)
There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the...原创 2019-12-06 19:24:22 · 214 阅读 · 0 评论 -
PAT甲级 - 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...原创 2019-12-05 20:19:54 · 174 阅读 · 0 评论 -
PAT甲级 -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 ne...原创 2019-12-04 21:26:54 · 210 阅读 · 0 评论 -
PAT甲级 - 1098 Insertion or Heap Sort (25 分) 堆排序,找规律
According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data...原创 2019-12-04 11:25:04 · 250 阅读 · 0 评论 -
PAT甲级 - 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 the...原创 2019-12-02 21:58:30 · 195 阅读 · 0 评论 -
PAT甲级1066 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 i...原创 2019-12-02 18:12:43 · 190 阅读 · 0 评论 -
PAT甲级 - 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 s...原创 2019-12-01 22:08:46 · 183 阅读 · 0 评论 -
PAT - 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 s...原创 2019-12-01 21:32:08 · 195 阅读 · 0 评论 -
PAT甲级 - 1094 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-12-01 18:50:36 · 165 阅读 · 0 评论 -
PAT甲级 - 1090 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 t...原创 2019-12-01 18:12:56 · 200 阅读 · 0 评论 -
PAT甲级 - 1079 Total Sales of Supply Chain (25 分) 树+BFS
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 t...原创 2019-11-30 21:51:08 · 252 阅读 · 0 评论 -
PAT甲级 - 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 tur...原创 2019-11-30 19:40:32 · 233 阅读 · 1 评论 -
PAT甲级- 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 sta...原创 2019-11-30 18:09:44 · 185 阅读 · 0 评论 -
PAT甲级1105 Spiral Matrix (25 分) 模拟
This time your job is to fill a sequence ofNpositive integers into aspiral matrixin non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then mov...原创 2019-11-29 21:48:27 · 176 阅读 · 0 评论 -
PAT甲级 - 1057 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 P...原创 2019-11-28 23:16:36 · 275 阅读 · 0 评论 -
PAT甲级 - 1068 Find More Coins (30 分) DFS 和DP
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 of coins as payments. However...原创 2019-11-28 20:42:09 · 208 阅读 · 0 评论 -
PAT甲级 -1045 Favorite Color Stripe (30 分)
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 p...原创 2019-11-27 20:30:00 · 237 阅读 · 0 评论 -
PAT甲级 - 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 ...原创 2019-11-17 12:42:03 · 159 阅读 · 0 评论 -
PAT甲级 - 1003 Emergency (25 分) Dijstra和BF算法
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 ...原创 2019-11-15 12:35:45 · 246 阅读 · 0 评论 -
PAT - 1076 Forwards on Weibo (30 分) 图的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-11-13 23:14:25 · 182 阅读 · 0 评论 -
PAT - 1034 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 ...原创 2019-11-13 16:16:47 · 171 阅读 · 0 评论 -
PAT- 并查集-好朋友
并查集的重点是维护一个father数组,来表明各结点间的关系【好朋友】1. 问题描述:有一个叫做“数码世界”奇异空间,在数码世界里生活着许许多多的数码宝贝,其中有些数码宝贝之间可能是好朋友,并且数码宝贝世界有两条不成文的规定:第一,数码宝贝A和数码宝贝B是好朋友等价于数码宝贝B与数码宝贝A是好朋友第二,如果数码宝贝A和数码宝贝C是好朋友,而数码宝贝B和数码宝贝C也是好朋友,那...原创 2019-11-12 21:48:09 · 390 阅读 · 0 评论 -
PAT - 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 s...原创 2019-11-09 13:02:51 · 197 阅读 · 0 评论 -
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 fr...原创 2019-11-08 13:53:34 · 164 阅读 · 0 评论 -
PAT - 1020 Tree Traversals
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 co...原创 2019-11-08 10:49:29 · 135 阅读 · 0 评论 -
PAT - BFS
例题1,给出一个m*n的矩阵,矩阵中的元素为0或1,称位置x与其上下左右四个位置是相邻的。若有若干个1相邻,成这些1构成了一个块。例如如下的矩阵中输入样例: 6 7 0 1 1 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0 1 1 1 0 1 0 0 1 1 1 1 0 0 0...原创 2019-11-05 16:21:45 · 192 阅读 · 0 评论 -
PAT - 栈、队列、链表
【Codeup 1918】简单计算器数据结构node,用来存储操作数和操作符,flag来表示类型 stack操作符栈【遇到相等或者高优先级操作符,弹出】;queue用来存储转换成的后缀表达式;map实现操作符优先级的映射。 使用(getline(cin, str), str!= "0"),来输入若干字符串str,str = "0",终止输入。 使用 string::iterator i...原创 2019-10-31 22:05:11 · 319 阅读 · 0 评论 -
PAT - 数学类总结
PAT A 1069The Black Hole of Numbers(20分)学习点:1.整型数组和整数的相互转换,整型数组排序实现倒序2. %04d进行输出,实现缺0补0.#include<cstdio>#include<algorithm>using namespace std;bool cmp(int a, int b){ ...原创 2019-10-24 16:08:40 · 265 阅读 · 0 评论 -
1101 Quick Sort (25 分)- PAT甲级真题-多种算法及分析
There is a classical process namedpartitionin the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its l...原创 2019-10-22 13:16:14 · 899 阅读 · 3 评论