自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(35)
  • 收藏
  • 关注

原创 11-散列4 Hashing - Hard Version (30分)

Given a hash table of size N, we can define a hash function . Suppose that the linear probing is used to solve collisions, we can easily obtain the status of the hash table with a given sequence of in

2016-11-19 23:17:51 1215

原创 11-散列3 QQ帐户的申请与登陆 (25分)

实现QQ新帐户申请和老帐户登陆的简化版功能。最大挑战是:据说现在的QQ号码已经有10位数了。输入格式:输入首先给出一个正整数N(≤10^5 ),随后给出NN行指令。每行指令的格式为:“命令符(空格)QQ号码(空格)密码”。其中命令符为“N”(代表New)时表示要新申请一个QQ号,后面是新帐户的号码和密码;命令符为“L”(代表Login)时表示是老帐户登陆,后面是登陆信息。QQ号码为一个不超

2016-11-19 18:31:31 1750

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

2016-11-19 11:53:49 3382

原创 11-散列1 电话聊天狂人 (25分)

给定大量手机用户通话记录,找出其中通话次数最多的聊天狂人。输入格式:输入首先给出正整数N(≤10^5),为通话记录条数。随后N行,每行给出一条通话记录。简单起见,这里只列出拨出方和接收方的11位数字构成的手机号码,其中以空格分隔。输出格式:在一行中给出聊天狂人的手机号码及其通话次数,其间以空格分隔。如果这样的人不唯一,则输出狂人中最小的号码及其通话次数,并且附加给出并列狂人的人数。

2016-11-18 22:22:19 3217

原创 10-排序6 Sort with Swap(0, i) (25分)

Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2

2016-11-14 18:59:25 1808 1

原创 10-排序5 PAT Judge (25分)

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 fil

2016-11-14 13:11:59 1941 1

原创 10-排序4 统计工龄 (20分)

给定公司N名员工的工龄,要求按工龄增序输出每个工龄段有多少员工。输入格式:输入首先给出正整数N(≤10^5),即员工总人数;随后给出N个整数,即每个员工的工龄,范围在[0, 50]。输出格式:按工龄的递增顺序输出每个工龄的员工个数,格式为:“工龄:人数”。每项占一行。如果人数为0则不输出该项。输入样例:810 2 0 5 7 2 5 2输出样

2016-11-14 09:44:23 2562

原创 09-排序3 Insertion or Heap Sort (25分)

According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data,

2016-11-14 09:34:18 1010

原创 09-排序2 Insert or Merge (25分)

According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data,

2016-11-14 09:13:43 2019 2

原创 09-排序1 排序 (25分)

给定N个(长整型范围内的)整数,要求输出从小到大排序后的结果。本题旨在测试各种不同的排序算法在各种数据情况下的表现。各组测试数据特点如下:数据1:只有1个元素;数据2:11个不相同的整数,测试基本正确性;数据3:10^3个随机整数;数据4:10^4个随机整数;数据5:10^5个随机整数;数据6:10^5个顺序整数;数据7:10^5个逆序整数;数据8:10^5个基

2016-11-09 21:42:55 4569 1

原创 08-图9 关键活动 (30分)

假定一个工程项目由一组子任务构成,子任务之间有的可以并行执行,有的必须在完成了其它一些子任务后才能执行。“任务调度”包括一组子任务、以及每个子任务可以执行所依赖的子任务集。比如完成一个专业的所有课程学习和毕业设计可以看成一个本科生要完成的一项工程,各门课程可以看成是子任务。有些课程可以同时开设,比如英语和C程序设计,它们没有必须先修哪门的约束;有些课程则不可以同时开设,因为它们有先后的依赖

2016-11-09 11:03:10 1075

原创 08-图8 How Long Does It Take (25分)

Given the relations of all the activities of a project, you are supposed to find the earliest completion time of the project.Input Specification:Each input file contains one test case. Each

2016-11-08 21:05:56 625

原创 08-图7 公路村村通 (30分)

现有村落间道路的统计数据表中,列出了有可能建设成标准公路的若干条道路的成本,求使每个村落都有公路连通所需要的最低成本。输入格式:输入数据包括城镇数目正整数N(≤1000)和候选道路数目MM(≤3N);随后的M行对应M条道路,每行给出3个正整数,分别是该条道路直接连通的两个城镇的编号以及该道路改建的预算成本。为简单起见,城镇从1到N编号。输出格式:输出村村通需要的最低成本

2016-11-08 18:53:17 2767 4

原创 07-图6 旅游规划 (25分)

有了一张自驾旅游路线图,你会知道城市间的高速公路长度、以及该公路要收取的过路费。现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径。如果有若干条路径都是最短的,那么需要输出最便宜的一条路径。输入格式:输入说明:输入数据的第1行给出4个正整数NN、MM、SS、DD,其中NN(2\le N\le 5002≤N≤500)是城市的个数,顺便假设城市的编号为0~(

2016-11-08 16:14:42 4916

原创 07-图5 Saving James Bond - Hard Version (30分)

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 drug dealers. He was sent to a small piece of land

2016-11-06 21:46:10 2921

原创 07-图4 哈利·波特的考试 (25分)

哈利·波特要考试了,他需要你的帮助。这门课学的是用魔咒将一种动物变成另一种动物的本事。例如将猫变成老鼠的魔咒是haha,将老鼠变成鱼的魔咒是hehe等等。反方向变化的魔咒就是简单地将原来的魔咒倒过来念,例如ahah可以将老鼠变成猫。另外,如果想把猫变成鱼,可以通过念一个直接魔咒lalala,也可以将猫变老鼠、老鼠变鱼的魔咒连起来念:hahahehe。现在哈利·波特的手里有一本教材,里面列出了所

2016-11-06 21:44:06 684

原创 06-图3 六度空间 (30分)

“六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”“六度空间”理论虽然得到广泛的认同,并且正在得到越来越多的应用。但是数十年来,试图验证这个理论始终是许多社会学家努力追求的目标。然而由于历史的原因,这样的研究具有太大

2016-11-06 11:29:15 709

原创 06-图2 Saving James Bond - Easy Version (25分)

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 drug dealers. He was sent to a small piece of land

2016-11-06 10:33:09 397

原创 06-图1 列出连通集 (25分)

给定一个有N个顶点和E条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到N−1编号。进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点。输入格式:输入第1行给出2个整数N(0输出格式:按照"{ v1 v2 vk }"的格式,每行输出一个连通集。先输出DFS的结果,再输出BFS的结果。输入样例:8 60 7

2016-11-05 18:40:17 1506

原创 05-树10 Huffman Codes (30分)

In 1953, David A. Huffman published his paper "A Method for the Construction of Minimum-Redundancy Codes", and hence printed his name in the history of computer science. As a professor who gives the f

2016-11-05 16:22:51 2513

原创 05-树9 File Transfer (25分)

We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer

2016-11-04 18:49:33 318

原创 05-树8 堆中的路径 (25分)

输入样例:5 346 23 26 24 105 4 3输出样例:24 23 1046 23 1026 10#include#include#define Mindata -10001int main() { int n, m; scanf("%d%d", &n, &m); if(n){ int i, j, x, *H; H = (i

2016-11-01 16:41:09 233

原创 04-树7 二叉搜索树的操作集 (30分)

本题要求实现给定二叉搜索树的5种常用操作。函数接口定义:BinTree Insert( BinTree BST, ElementType X );BinTree Delete( BinTree BST, ElementType X );Position Find( BinTree BST, ElementType X );Position FindMin( BinTre

2016-11-01 16:39:04 2231

原创 04-树6 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

2016-10-31 20:11:35 708

原创 04-树5 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

2016-10-28 18:20:04 3896

原创 04-树4 是否同一棵二叉搜索树 (25分)

给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。输入格式:输入包含若干组测试数据。每组数据的第1行给出两个正整数N(≤10)和L,分别是每个序列插入元素

2016-10-28 18:15:32 1077

原创 03-树3 Tree Traversals Again (25分)

Sample Input:6Push 1Push 2Push 3PopPopPush 4PopPopPush 5Push 6PopPopSample Output:3 4 2 6 5 1//由前序和中序建树,后序遍历树#include #include #include #include using n

2016-10-28 17:52:11 410

原创 03-树2 List Leaves (25分)

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 test case. For each case, the first line

2016-10-28 17:47:15 242

原创 03-树1 树的同构 (25分)

给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。现给定两棵树,请你判断它们是否是同构的。输入格式:输入给出2棵二叉树树的信息。对于每棵树,首先在一行中给出一个非负整数NN (\le 10≤10),即该

2016-10-28 17:43:30 280

原创 02-线性结构4 Pop Sequence (25分)

Sample Input:5 7 51 2 3 4 5 6 73 2 1 7 5 6 47 6 5 4 3 2 15 6 4 3 7 2 11 7 6 5 4 3 2Sample Output:YESNONOYESNO#include #include using namespace std;bool judge(vector v,

2016-10-27 23:50:26 755

原创 02-线性结构3 Reversing Linked List (25分)

Sample Input:00100 6 400000 4 9999900100 1 1230968237 6 -133218 3 0000099999 5 6823712309 2 33218Sample Output:00000 4 3321833218 3 1230912309 2 0010000100 1 9999999999 5

2016-10-27 23:42:38 1923 4

原创 02-线性结构2 一元多项式的乘法与加法运算 (20分)

设计函数分别求两个一元多项式的乘积与和。输入格式: 输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式: 输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应输出0 0。输入样例:4

2016-10-27 23:38:21 283

原创 02-线性结构1 两个有序链表序列的合并 (15分)

02-线性结构1 两个有序链表序列的合并   (15分)本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列。函数接口定义:List Merge( List L1, List L2 );其中List结构定义如下:typedef struct Node *PtrToNode;struct Node {    ElementType Data;

2016-10-27 23:36:29 1052 1

原创 01-复杂度2 Maximum Subsequence Sum (25分)

#include #include #define N 10000int main(void) { int arr[N]; int n, i = 0; int *a = arr; int sum = 0, temp = 0; int b = 0, e = 0, begin, end; scanf("%d", &n); while (i < n && scanf("%d", a

2016-10-27 23:31:25 211

原创 01-复杂度1 最大子列和问题 (20分)

01-复杂度1 最大子列和问题 (20分)

2016-10-27 23:19:09 208

空空如也

空空如也

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

TA关注的人

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