![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
深度优先搜索
Eighteen__
这个作者很懒,什么都没留下…
展开
-
1087 All Roads Lead to Rome(甲级)
1087 All Roads Lead to Rome (30分)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 input file contains one原创 2020-11-27 13:13:57 · 100 阅读 · 0 评论 -
1030 Travel Plan(甲级)
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 and原创 2020-11-26 10:28:27 · 183 阅读 · 0 评论 -
1021 Deepest Root(甲级)
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 called the deepest root.Inpu原创 2020-11-22 16:19:38 · 125 阅读 · 0 评论 -
1013 Battle Over Cities(甲级)
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 high原创 2020-11-22 15:21:42 · 70 阅读 · 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 of a原创 2020-11-21 12:18:21 · 93 阅读 · 0 评论 -
1110 Complete Binary Tree(甲级)
1110 Complete Binary Tree (25分)Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N (≤20) which is the total number of原创 2020-11-20 12:28:11 · 150 阅读 · 0 评论 -
1053 Path of Equal Weigh(甲级)
1053 Path of Equal Weight (30分)Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti . The weight of a path from R to L is defined to be the sum of the weights of all the nodes along the path from R to any leaf no原创 2020-11-20 10:31:47 · 80 阅读 · 0 评论 -
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.Starting from one root supplier, everyone on the chain buys prod原创 2020-11-18 22:41:36 · 68 阅读 · 0 评论 -
1004 Counting Leave(甲级)
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 containing 0<N&原创 2020-11-18 22:35:15 · 119 阅读 · 0 评论 -
1094 The Largest Generation(甲级)
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 inp原创 2020-11-18 19:03:34 · 52 阅读 · 0 评论 -
1090 Highest Price in Supply Chain(甲级)
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 pro原创 2020-11-18 17:47:22 · 56 阅读 · 0 评论 -
1079 Total Sales of Supply Chain(甲级)
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 produ原创 2020-11-18 17:18:38 · 76 阅读 · 0 评论 -
C++学习之路 | PTA(甲级)—— 1099 Build A Binary Search Tree (30分)(带注释)(精简)
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 cont原创 2020-10-14 23:17:04 · 212 阅读 · 0 评论 -
C++学习之路 | PTA(甲级)—— 1064 Complete Binary Search Tree (30分)(带注释)(精简)
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 node con原创 2020-10-14 23:02:02 · 106 阅读 · 0 评论 -
C++学习之路 | PTA(甲级)—— 1043 Is It a Binary Search Tree (25分)(带注释)(精简)
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:The left subtree of a node contains only nodes with keys less than the node’s key.The right subtree of a node cont原创 2020-10-14 22:43:50 · 108 阅读 · 0 评论 -
C++学习之路 | PTA(甲级)—— 1127 ZigZagging on a Tree (30分)(带注释)(精简)
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 the原创 2020-10-13 22:50:04 · 373 阅读 · 0 评论 -
C++学习之路 | PTA(甲级)—— 1020 Tree Traversals (25分)(带注释)(精简)
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 corresponding binary tree.Input原创 2020-10-13 22:37:26 · 125 阅读 · 0 评论