- 博客(146)
- 收藏
- 关注
原创 1139 First Contact (30分)
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instead, he might ask another boy ...
2020-05-16 00:18:09
269
原创 1131 Subway Map (30分)
In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are supposed to help people with your computer skills! Given the starting position of you...
2020-05-15 00:43:45
191
原创 1019 General Palindromic Number (20分)
A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Although palindromic numbers are most often considere.
2020-05-11 23:41:05
113
原创 1142 Maximal Clique (25分)
Acliqueis a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. Amaximal cliqueis a clique that cannot be extended by including one more adjacent vertex. (Quoted fromhttps://en.wikipedia.org/wiki...
2020-05-11 00:45:58
158
原创 1146 Topological Order (25分)[拓扑序列]
This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test each of the options.Input Specification:Each i...
2020-05-10 00:55:13
115
原创 1150 Travelling Salesman Problem (25分)
The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and returns to the origin city?" It is an NP-hard problem in ...
2020-05-09 00:45:55
105
原创 1154 Vertex Coloring (25分)
Aproper vertex coloringis 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 mostkcolors is called a (proper...
2020-05-08 00:53:31
83
原创 1134 Vertex Cover (25分)[模拟]
Avertex coverof a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell i...
2020-05-08 00:16:25
113
原创 1126 Eulerian Path (25分)
In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They were firs...
2020-05-06 00:48:22
152
原创 1111 Online Map (30分) [Dijkstra]
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...
2020-05-04 23:57:23
137
原创 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:Ea...
2020-05-03 01:26:47
113
原创 1135 Is It A Red-Black Tree (30分)
There is a kind of balanced binary search 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) Every...
2020-04-24 01:04:15
202
原创 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...
2020-04-23 01:25:47
118
原创 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...
2020-04-22 02:06:16
130
原创 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. ...
2020-04-21 00:22:59
175
原创 1127 ZigZagging on a Tree (30分)【重建二叉树/Z字型遍历二叉树】
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...
2020-04-17 01:49:23
283
原创 1026 Table Tennis (30分)
A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the ava...
2020-04-07 21:47:05
236
原创 1017 Queueing at Bank (25分)
Suppose a bank hasKwindows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow li...
2020-04-06 20:50:02
145
原创 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 ...
2020-03-18 00:25:49
101
原创 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 nee...
2020-03-17 00:22:41
73
原创 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 b...
2020-03-06 21:42:41
221
原创 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 ...
2020-03-04 00:01:18
488
原创 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 t...
2020-03-03 00:18:02
104
原创 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,...
2020-02-26 21:20:56
96
原创 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 thei...
2020-02-23 21:00:49
241
原创 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 is...
2020-02-22 21:00:16
233
原创 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 su...
2020-02-19 19:20:12
102
原创 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 su...
2020-02-19 18:53:39
97
原创 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...
2020-02-18 19:12:30
110
原创 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 th...
2020-02-18 18:45:06
83
原创 1094 The Largest Generation (25分)【BFS解法】
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 ...
2020-02-17 20:52:41
109
原创 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 th...
2020-02-16 19:50:30
98
原创 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 th...
2020-02-16 19:15:04
148
原创 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...
2020-02-15 20:40:40
87
原创 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 stac...
2020-02-08 01:16:37
77
原创 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 su...
2020-02-07 21:36:35
93
原创 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 fro...
2020-02-05 22:10:42
107
原创 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...
2020-02-04 00:03:50
120
原创 1091 Acute Stroke (30分)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to c...
2020-02-01 23:08:25
84
原创 1103 Integer Factorization (30分) 【DFS】
TheK−Pfactorization of a positive integerNis to writeNas the sum of theP-th power ofKpositive integers. You are supposed to write a program to find theK−Pfactorization ofNfor any positive...
2020-01-31 22:09:16
85
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅