自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 资源 (1)
  • 收藏
  • 关注

原创 1101 Quick Sort (25分) 简单dp

There is a classical process named partition in 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 le...

2020-04-10 23:53:29 138

原创 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 subt...

2020-04-10 23:28:59 202

原创 1095 Cars on Campus (30分)结构体排序

Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you a...

2020-04-10 20:00:56 170

原创 1091 Acute Stroke (30分)测试点4和5

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-04-10 15:53:20 430

原创 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-04-09 10:02:30 79

原创 1085 Perfect Sequence (25分) 测试点5

Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum numbers in the sequence, respecti...

2020-04-09 09:30:25 532 1

原创 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...

2020-04-08 21:36:03 93

原创 1075 PAT Judge (25分) 测试点4分析

The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file cont...

2020-04-02 23:20:03 596

原创 1074 Reversing Linked List (25分)

Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→4; if K=4,...

2020-04-02 20:40:44 116

原创 1068 Find More Coins (30分)

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,...

2020-04-02 00:02:49 133

原创 1038 Recover the Smallest Number (30分)

Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229...

2020-03-22 10:44:57 76

原创 1037 Magic Coupon (25分)

The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product b...

2020-03-22 10:17:39 136 1

原创 1034 Head of a Gang (30分)c++ 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 between A and B, we say that A and B is related. The weight of a relation is defined to be t...

2020-03-21 00:03:48 100

原创 1022 Digital Library (30分)

A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number a...

2020-03-19 16:31:35 127

原创 codeup问题 A: 第二题 提供测试样例

题目描述一个数组中有若干正整数,将此数组划分为两个子数组,使得两个子数组各元素之和a,b的差最小,对于非法输入应该输出ERROR。输入数组中的元素输出降序输出两个子数组的元素和样例输入 Copy10 20 30 10 1010 20 abc 10 10样例输出 Copy40 40ERROR思路:1.先getline处理读入的字符串,每读到一个空格,就可以判断一个子串是不是...

2020-03-17 11:43:04 454 1

原创 codeup问题 B: 确定比赛名次

时间限制 : 1.000 sec 内存限制 : 32 MB题目描述有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。输入输入有若干组,每组中的第一...

2020-03-16 09:41:38 210

原创 codeup问题 A: 算法7-12:有向无环图的拓扑排序

题目描述由某个集合上的一个偏序得到该集合上的一个全序,这个操作被称为拓扑排序。偏序和全序的定义分别如下:若集合X上的关系R是自反的、反对称的和传递的,则称R是集合X上的偏序关系。设R是集合X上的偏序,如果对每个x,y∈X必有xRy或yRx,则称R是集合X上的全序关系。由偏序定义得到拓扑有序的操作便是拓扑排序。拓扑排序的流程如下: 在有向图中选一个没有前驱的顶点并且输出之;...

2020-03-16 09:03:41 572

原创 codeup问题 A: 关键路径 提供测试样例

时间限制 : 1.000 sec 内存限制 : 128 MB题目描述描述:图的连接边上的数据表示其权值,带权值的图称作网。上图可描述为顶点集为(a,b,c,d,e)边集及其权值为(始点,终点 权值):a b 3a c 2b d 5c d 7c e 4d e 6网的源点是入度为0的顶点,汇点是出度为0的顶点。网的关键路径是指从源点到汇点的所有路径中,具有最大路径长度的路径。...

2020-03-15 21:08:05 486 1

原创 codeup问题 E: Jungle Roads

题目描述 The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentless...

2020-03-15 18:25:27 145

原创 coudeup问题 D: 继续畅通工程

时间限制 : 1.000 sec 内存限制 : 32 MB题目描述省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。输入测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ...

2020-03-15 17:08:30 146

原创 codeup问题 B: Freckles

题目描述In an episode of the Dick Van Dyke show, little Richie connects the freckles on his Dad’s back to form a picture of the Liberty Bell. Alas, one of the freckles turns out to be a scar, so his Ripl...

2020-03-15 16:43:10 314

原创 1135 Is It A Red-Black Tree (30分) 提供测试样例参考

题目大意:根据红黑树的判断规则,输入一个树的先序遍历,判断这个树是不是红黑树。思路:无脑建树~1.由于是搜索树,中序遍历就是结点从小到大排序。2.dfs搜索每一条根结点到叶子结点NULL的路径。(注意叶子结点是NULL!我一开始就没有理解题意,所以测试点2,3被卡了一下)3.判断路径是不是符合题目给出的规则。提供一个测试样例:131 2 -3No应该题目给的样例+这个样例能通...

2020-03-12 00:50:42 1307

原创 1017 Queueing at Bank (25分)排序水题

Suppose a bank has K windows 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-03-11 09:35:41 131

原创 PAT A1155 Heap Paths (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...

2020-03-08 20:48:44 70

原创 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...

2020-03-07 01:46:27 116

原创 1122 Hamiltonian Cycle (25分) 层序遍历思想+测试点4样例

写完层序遍历发现一直测试点4过不去,后面自己设计了挺多样例,发现自己count++位置写错。总结点树分奇偶讨论确实这个方法一般般判断很容易出错。//测试点4推荐样例:71 23 45 -6 -- -- -- -思想:有奇数num个结点时,前(int)num/2个结点左右孩子都要有。有偶数num个结点时,前(int)num/2-1个结点要有左右孩子,第(int)num/2个...

2020-03-05 13:54:20 540

原创 1112 Stucked Keyboard (20分) 测试点2,3,4分析及测试样例

测试点3建议样例:3aaasssccc测试点2,4:注意输出可能坏键的字符顺序是按照字符串中出现的顺序。下面讲讲我的思路:设置map<char, bool > map1;存储出现过的字符,false表示不是坏键,true表示是坏键。然后处理字符串,字符每次和前一个比较,如果一样就len++。不一样就看map1中有没有出现过这个字符:1.如果map1中有,并且为false...

2020-03-04 21:01:20 881

原创 1072 Gas Station (30分)

A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou...

2020-03-03 15:33:37 131

原创 1080 MOOC期终成绩 (25分) 对map的value排序

对于在中国大学MOOC(http://www.icourse163.org/ )学习“数据结构”课程的学生,想要获得一张合格证书,必须首先获得不少于200分的在线编程作业分,然后总评获得不少于60分(满分100)。总评成绩的计算公式为 G=(G​mid−term​​×40%+G​final​​×60%),如果 G​mid−term​​>G​final​​;否则总评 G 就是 G​final​...

2020-03-01 05:19:02 104

原创 1058 选择题 (20分)测试点0与123有略微不同

批改多选题是比较麻烦的事情,本题就请你写个程序帮助老师批改多选题,并且指出哪道题错的人最多。输入格式:输入在第一行给出两个正整数 N(≤ 1000)和 M(≤ 100),分别是学生人数和多选题的个数。随后 M 行,每行顺次给出一道题的满分值(不超过 5 的正整数)、选项个数(不少于 2 且不超过 5 的正整数)、正确选项个数(不超过选项个数的正整数)、所有正确选项。注意每题的选项从小写英文字母...

2020-02-28 18:32:15 645

原创 1055 集体照 (25分)水题

拍集体照时队形很重要,这里对给定的 N 个人 K 排的队形设计排队规则如下:每排人数为 N/K(向下取整),多出来的人全部站在最后一排;后排所有人的个子都不比前排任何人矮;每排中最高者站中间(中间位置为 m/2+1,其中 m 为该排人数,除法向下取整);每排其他人以中间人为轴,按身高非增序,先右后左交替入队站在中间人的两侧(例如5人身高为190、188、186、175、170,则队形...

2020-02-28 13:11:07 221

原创 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...

2020-02-14 19:44:30 631

原创 1065 A+B and C (64bit) (20分)

Given three integers A, B and C in [−2​63​​,2​63​​], you are supposed to tell whether A+B>C.Input Specification:The first line of the input gives the positive number of test cases, T (≤10). Then ...

2020-02-05 18:25:43 117

原创 1046 Shortest Distance (20分)

The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file contain...

2020-02-05 17:43:15 76

原创 HDU 4022 Bombing c++解法

It’s a cruel war which killed millions of people and ruined series of cities. In order to stop it, let’s bomb the opponent’s base.It seems not to be a hard work in circumstances of street battles, ho...

2020-01-18 18:08:40 443

原创 c++ HDU 1279 士兵队列训练问题

题目描述:某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流进行一至二报数、一至三报数直到剩下的人数不超过三人为止。Input本题有多个测试数据组,第一行为组数N,接着为N行新兵人数...

2020-01-17 20:58:10 920

原创 Problem-2054 A == B ?

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 152755 Accepted Submission(s): 24759Problem DescriptionGive you two numbers A and B, if A ...

2020-01-16 02:23:17 93

c语言语法制导翻译器翻译三元式.zip

语法制导翻译器,将算术表达式翻译成三元式。 确定一个定义算术表达式的文法,为其设计一个语法分析程序,为每条产生式配备一个语义子程序,按照一遍扫描的语法制导翻译方法,实现翻译程序。对用户输入的任意一个正确的算术表达式,程序将其转换成三元式输出。

2020-03-29

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除