摘要: 10-5 10-6 11-1 11-2 11-3 11-4 KMP 阅读全文
posted @ 2019-05-28 10:48 Acoccus 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 给定公司N名员工的工龄,要求按工龄增序输出每个工龄段有多少员工。 输入格式: 输入首先给出正整数N(≤),即员工总人数;随后给出N个整数,即每个员工的工龄,范围在[0, 50]。 输出格式: 按工龄的递增顺序输出每个工龄的员工个数,格式为:“工龄:人数”。每项占一行。如果人数为0则不输出该项。 输入 阅读全文
posted @ 2019-05-28 10:40 Acoccus 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 排序算法大汇总,缺少基数排序,需要自己再写一遍 1 #include <cstdio> 2 #include <stdlib.h> 3 #include <algorithm> 4 using namespace std; 5 const int CUTOFF = 50; 6 7 typedef i 阅读全文
posted @ 2019-05-28 10:38 Acoccus 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 假定一个工程项目由一组子任务构成,子任务之间有的可以并行执行,有的必须在完成了其它一些子任务后才能执行。“任务调度”包括一组子任务、以及每个子任务可以执行所依赖的子任务集。 比如完成一个专业的所有课程学习和毕业设计可以看成一个本科生要完成的一项工程,各门课程可以看成是子任务。有些课程可以同时开设,比 阅读全文
posted @ 2019-05-28 10:37 Acoccus 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #define MaxVertexNum 102 5 #define INFINITY 65536 6 using namespace std; 7 8 typedef int Vertex; 9 typedef int WeightType; ... 阅读全文
posted @ 2019-05-28 10:36 Acoccus 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 1 /* 图的邻接矩阵表示法 */ 2 #include 3 #include 4 5 #define MaxVertexNum 1001 /* 最大顶点数设为100 */ 6 #define INFINITY 65535 /* ∞设为双字节无符号整数的最大值65535*/ 7 #define ERROR -1 8 typedef int... 阅读全文
posted @ 2019-05-28 10:36 Acoccus 阅读(429) 评论(0) 推荐(0) 编辑
摘要: 1 #include <cstdio> 2 #include <stdlib.h> 3 const int INFINITY = 65536; 4 const int MaxVertexNum = 501; 5 const int ERROR = -1; 6 int dist[MaxVertexNu 阅读全文
posted @ 2019-05-28 10:35 Acoccus 阅读(252) 评论(0) 推荐(0) 编辑
摘要: This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous spy, was captured by a group of d 阅读全文
posted @ 2019-05-28 10:30 Acoccus 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 哈利·波特要考试了,他需要你的帮助。这门课学的是用魔咒将一种动物变成另一种动物的本事。例如将猫变成老鼠的魔咒是haha,将老鼠变成鱼的魔咒是hehe等等。反方向变化的魔咒就是简单地将原来的魔咒倒过来念,例如ahah可以将老鼠变成猫。另外,如果想把猫变成鱼,可以通过念一个直接魔咒lalala,也可以将 阅读全文
posted @ 2019-05-28 10:29 Acoccus 阅读(305) 评论(0) 推荐(0) 编辑
摘要: This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous spy, was captured by a group of d 阅读全文
posted @ 2019-05-28 10:28 Acoccus 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 给定一个有N个顶点和E条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到N−1编号。进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点。 输入格式: 输入第1行给出2个整数N(0)和E,分别是图的顶点数和边数。随后E行,每行给出一条边的两个端点。每行中的数字 阅读全文
posted @ 2019-05-28 10:27 Acoccus 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2019-05-28 10:24 Acoccus 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。 输入格式: 输入包含若干组 阅读全文
posted @ 2019-05-28 10:23 Acoccus 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2019-05-28 10:22 Acoccus 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given a tree, you are supposed to list all the leaves in the order of top down, and left to right. Input Specification: Each input file contains one t 阅读全文
posted @ 2019-05-28 10:21 Acoccus 阅读(167) 评论(0) 推荐(0) 编辑
摘要: #include #define MaxTree 12 #define ElementType char #define Null -1 #define Tree int struct TreeNode { ElementType element; Tree left; Tree right; }t1[MaxTree], t2[MaxTree]; Tree build... 阅读全文
posted @ 2019-05-28 10:19 Acoccus 阅读(217) 评论(0) 推荐(0) 编辑
摘要: Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given s 阅读全文
posted @ 2019-05-28 10:18 Acoccus 阅读(582) 评论(0) 推荐(0) 编辑
摘要: 1 #include <cstdio> 2 #include <stdlib.h> 3 typedef struct Node* Polynomial; 4 struct Node { 5 int coef; 6 int expon; 7 Polynomial next; 8 }; 9 10 voi 阅读全文
posted @ 2019-05-28 10:16 Acoccus 阅读(339) 评论(0) 推荐(0) 编辑
摘要: 1 #include <cstdio> 2 #define Null -1 3 4 const int maxn = 1e5+2; 5 struct Node { 6 int data; 7 int addr, next; 8 } Lst[maxn]; 9 10 11 12 int input(in 阅读全文
posted @ 2019-05-28 10:16 Acoccus 阅读(245) 评论(0) 推荐(0) 编辑
摘要: Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i+1​​, ..., N​j​​ } where 1. The Max 阅读全文
posted @ 2019-05-28 10:14 Acoccus 阅读(127) 评论(0) 推荐(0) 编辑