![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT
zadarmo_
这个作者很懒,什么都没留下…
展开
-
1057 Stack (30分)——甲级(栈、树状数组、二分)
Description: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 pos...原创 2019-12-17 20:41:27 · 158 阅读 · 0 评论 -
1032 Sharing (25分)——甲级(链表、map映射)
Description: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....原创 2019-12-16 20:54:11 · 93 阅读 · 0 评论 -
1013 Battle Over Cities (25 分)——甲级(dfs求连通分量)
Description: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 immediat...原创 2019-11-30 14:15:53 · 101 阅读 · 0 评论 -
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 people who have some of thei...原创 2019-08-21 20:56:23 · 1002 阅读 · 0 评论 -
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 differ by more than one, rebalancing is...原创 2019-08-16 18:03:55 · 546 阅读 · 1 评论 -
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 stand...原创 2019-08-16 19:22:21 · 201 阅读 · 0 评论 -
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 than or equal to (i...原创 2019-08-17 13:35:53 · 90 阅读 · 0 评论 -
1155 Heap Paths (30 分)——甲级(堆+dfs回溯)
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 than or equal to (i...原创 2019-08-17 14:06:29 · 151 阅读 · 0 评论 -
11-散列4 Hashing - Hard Version (30 分)(哈希+拓扑排序+优先队列)
Given a hash table of size N, we can define a hash function H(x)=x%N. Suppose that the linear probing is used to solve collisions, we can easily obtain the status of the hash table with a given sequen...原创 2019-08-22 20:59:11 · 331 阅读 · 0 评论 -
1030 Travel Plan (30 分)——甲级(Djkstra变形+记录路径)
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 b...原创 2019-08-23 12:11:32 · 227 阅读 · 0 评论 -
1034 Head of a Gang (30 分)——甲级(连通分量+map)
One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be t...原创 2019-08-27 12:40:01 · 109 阅读 · 0 评论 -
1003 Emergency (25 分)——甲级(Dijkstra变形)
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 l...原创 2019-08-31 22:43:57 · 132 阅读 · 0 评论 -
1087 All Roads Lead to Rome (30 分)——甲级(Dijkstra复杂变形+记录路径+map)
Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each in...原创 2019-09-01 16:27:13 · 238 阅读 · 0 评论 -
1111 Online Map (30 分)——甲级(2次Dijkstra+记录路径+vector)
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 g...原创 2019-09-02 19:37:03 · 123 阅读 · 0 评论 -
11-散列3 QQ帐户的申请与登陆 (25 分)(哈希/map)
实现QQ新帐户申请和老帐户登陆的简化版功能。最大挑战是:据说现在的QQ号码已经有10位数了。输入格式:输入首先给出一个正整数N(≤105 ),随后给出N行指令。每行指令的格式为:“命令符(空格)QQ号码(空格)密码”。其中命令符为“N”(代表New)时表示要新申请一个QQ号,后面是新帐户的号码和密码;命令符为“L”(代表Login)时表示是老帐户登陆,后面是登陆信息。QQ号码为一个不...原创 2019-08-21 15:26:56 · 1167 阅读 · 3 评论 -
1023 Have Fun with Numbers (20 分)——甲级(高精度乘法)
Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con...原创 2019-08-26 00:08:05 · 176 阅读 · 0 评论 -
1102 Invert a Binary Tree (25 分)——甲级:建树输出中序、层序(二叉树镜像输出)
The following is from Max Howell @twitter:Now it’s your turn to prove that YOU CAN invert a binary tree!Input Specification:Each input file contains one test case. For each case, the first line gi...原创 2019-08-13 15:02:02 · 281 阅读 · 3 评论 -
1020 Tree Traversals (25 分)——甲级:已知后序、中序,输出层序(二叉树、对于建树递归算法的理解)
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 cor...原创 2019-08-13 16:43:20 · 128 阅读 · 0 评论 -
给定二叉树的前序和后序,判断二叉树是否唯一?
对于一棵二叉树,如果给定中序和前序后序任意一个,是可以确定这个树的形状的。例如给定前序和中序:前序第一个结点肯定是根节点,后面是:1.左子树、右子树2.只有左子树3.只有右子树对于前序中的根节点,在中序找找到位置后,他的左边有元素就有左子树,右边有元素就有右子树。所以结合以上两点是可以唯一确定一棵二叉树的。而如果把中序换成后序: 因为后序是左-右-根,无法从后序中判断前序中根节点...原创 2019-08-13 16:47:26 · 11368 阅读 · 4 评论 -
1099 Build A Binary Search Tree (30 分)——甲级:建树,输出层序(二叉搜索树)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:Given the structure of a binary tree and a sequence of distinct integer keys, there is only one ...原创 2019-08-13 18:38:34 · 940 阅读 · 0 评论 -
1010 Radix (25 分)——甲级(二分)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integ...原创 2019-08-07 14:55:53 · 112 阅读 · 0 评论 -
1132 Cut Integer (20 分)——甲级(atoi函数)
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...原创 2019-08-19 12:33:50 · 95 阅读 · 0 评论 -
1118 Birds in Forest (25 分)——甲级(并查集+set)
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 maxi...原创 2019-08-19 15:55:53 · 145 阅读 · 0 评论 -
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 from the table and output the average sea...原创 2019-08-19 18:20:10 · 202 阅读 · 0 评论 -
11-散列1 电话聊天狂人 (25 分)(哈希:除留余数法、分离链接法)
(第一次接触哈希,先从一个一个题目开始慢慢理解吧 。。)给定大量手机用户通话记录,找出其中通话次数最多的聊天狂人。输入格式:输入首先给出正整数N(≤105),为通话记录条数。随后N行,每行给出一条通话记录。简单起见,这里只列出拨出方和接收方的11位数字构成的手机号码,其中以空格分隔。输出格式:在一行中给出聊天狂人的手机号码及其通话次数,其间以空格分隔。如果这样的人不唯一,则输出狂人中最...原创 2019-08-17 21:47:00 · 774 阅读 · 0 评论 -
11-散列2 Hashing (25 分)(哈希:除留余数法、二次探测法)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be H(key)=key%TSiz...原创 2019-08-18 10:50:00 · 845 阅读 · 0 评论 -
1154 Vertex Coloring (25 分)——甲级(set)
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...原创 2019-08-11 17:39:12 · 151 阅读 · 0 评论 -
1043 Is It a Binary Search Tree (25 分)——甲级(二叉搜索树)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:If we swap the left and right subtrees of every node, then the resulting tree is called the Mirr...原创 2019-08-15 21:50:16 · 116 阅读 · 0 评论 -
1064 Complete Binary Search Tree (30 分)——甲级(完全二叉搜索树)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:A Complete Binary Tree (CBT) is a tree that is completely filled, with the possible exception of...原创 2019-08-15 22:27:31 · 122 阅读 · 0 评论 -
1004 Counting Leaves (30 分)——甲级(dfs)
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 w...原创 2019-08-06 00:00:10 · 89 阅读 · 0 评论