随笔分类 -  日常作业

摘要:描述 给定一个长度为n(n<=10^6)的数组。有一个大小为k的滑动窗口从数组的最左端移动到最右端。你可以看到窗口中的k个数字。窗口每次向右滑动一个数字的距离。 下面是一个例子: 数组是 [1 3 -1 -3 5 3 6 7], k = 3。 窗口位置最小值最大值 [1 3 -1] -3 5 3 6 阅读全文
posted @ 2018-12-16 15:17 TobicYAL 阅读(972) 评论(0) 推荐(0)
摘要:描述 The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days: his mother is getting ill. Being wo 阅读全文
posted @ 2018-12-10 18:04 TobicYAL 阅读(221) 评论(0) 推荐(0)
摘要:描述 Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like trad 阅读全文
posted @ 2018-12-10 17:59 TobicYAL 阅读(459) 评论(2) 推荐(0)
摘要:发现他,抓住他(10分) 题目内容: 一个城市中有两个犯罪团伙A和B,你需要帮助警察判断任意两起案件是否是同一个犯罪团伙所为,警察所获得的信息是有限的。假设现在有N起案件(N<=100000),编号为1到N,每起案件由团伙A或团伙B所为。你将按时间顺序获得M条信息(M<=100000),这些信息分为 阅读全文
posted @ 2018-12-05 22:50 TobicYAL 阅读(1700) 评论(0) 推荐(0)
摘要:求逆序对数(10分) 求逆序对数(10分) 题目内容: 对于一个长度为N的整数序列A,满足i < j 且 Ai > Aj.的数对(i,j)称为整数序列A的一个逆序<j<=n且ai><j<=n且ai><j<=n且ai><j<=n且ai> 请求出整数序列A的所有逆序对个数 输入格式: 输入包含多组测试数 阅读全文
posted @ 2018-11-28 15:04 TobicYAL 阅读(608) 评论(0) 推荐(0)
摘要:描述 Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering problems, all 阅读全文
posted @ 2018-11-26 19:33 TobicYAL 阅读(300) 评论(0) 推荐(0)
摘要:描述 FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows. A set of paths of various lengths ru 阅读全文
posted @ 2018-11-26 19:29 TobicYAL 阅读(242) 评论(0) 推荐(0)
摘要:描述 As you know, all the computers used for ACM contests must be identical, so the participants compete on equal terms. That is why all these computers 阅读全文
posted @ 2018-11-23 18:19 TobicYAL 阅读(282) 评论(0) 推荐(0)
摘要:兔子与星空(10分) 题目内容: 很久很久以前,森林里住着一群兔子。兔子们无聊的时候就喜欢研究星座。如图所示,天空中已经有了n颗星星,其中有些星星有边相连。兔子们希望删除掉一些边,然后使得保留下的边仍能是n颗星星连通。他们希望计算,保留的边的权值之和最小是多少? 输入格式: 第一行只包含一个表示星星 阅读全文
posted @ 2018-11-20 15:41 TobicYAL 阅读(1026) 评论(0) 推荐(0)
摘要:描述 Consider the two networks shown below. Assuming that data moves around these networks only between directly connected nodes on a peer-to-peer basis 阅读全文
posted @ 2018-11-16 18:42 TobicYAL 阅读(259) 评论(0) 推荐(0)
摘要:描述 Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exch 阅读全文
posted @ 2018-11-16 18:38 TobicYAL 阅读(251) 评论(0) 推荐(0)
摘要:二叉树的深度(10分) 题目内容: 给定一棵二叉树,求该二叉树的深度 二叉树深度定义:从根结点到叶结点依次经过的结点(含根、叶结点)形成树的一条路径,最长路径的节点个数为树的深度 输入格式: 第一行是一个整数n,表示二叉树的结点个数。二叉树结点编号从1到n,根结点为1,n <= 10 接下来有n行, 阅读全文
posted @ 2018-11-13 15:28 TobicYAL 阅读(804) 评论(0) 推荐(0)
摘要:描述 Caocao was defeated by Zhuge Liang and ZhouYu in the battle of Chibi. But he wouldn't give up. Caocao's army still was not good at water battles, s 阅读全文
posted @ 2018-11-08 09:53 TobicYAL 阅读(352) 评论(0) 推荐(0)
摘要:描述 In order to make their sons brave, Jiajia and Wind take them to a big cave. The cave has n rooms, and one-way corridors connecting some rooms. Each 阅读全文
posted @ 2018-11-08 09:47 TobicYAL 阅读(318) 评论(0) 推荐(0)
摘要:描述 Every cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) o 阅读全文
posted @ 2018-11-08 09:31 TobicYAL 阅读(290) 评论(0) 推荐(0)
摘要:题目内容: 我们知道如何按照三种深度优先次序来周游一棵二叉树,来得到中根序列、前根序列和后根序列。反过来,如果给定二叉树的中根序列和后根序列,或者给定中根序列和前根序列,可以重建一二叉树。本题输入一棵二叉树的中根序列和后根序列,要求在内存中重建二叉树,最后输出这棵二叉树的前根序列。 用不同的整数来唯 阅读全文
posted @ 2018-11-02 20:41 TobicYAL 阅读(2420) 评论(0) 推荐(0)
摘要:描述 Biologists finally invent techniques of repairing DNA that contains segments causing kinds of inherited diseases. For the sake of simplicity, a DNA 阅读全文
posted @ 2018-10-29 23:26 TobicYAL 阅读(454) 评论(0) 推荐(0)
摘要:描述 有若干种病毒,每种病毒的特征代码都是一个01串。 每个程序也都是一个01串。 问是否存在不被病毒感染(不包含任何病毒的特征代码)的无限长的程序。 输入第一行是整数n,表示有n个病毒接下来n行,每行是一个由 0,1构成的字符串,表示一个病毒特征代码所有的病毒的特征代码总长度不超过30000输出如 阅读全文
posted @ 2018-10-29 23:24 TobicYAL 阅读(1195) 评论(0) 推荐(0)
摘要:描述 Aliens on planet Pandora also write computer programs like us. Their programs only consist of capital letters (‘A’ to ‘Z’) which they learned from 阅读全文
posted @ 2018-10-29 23:18 TobicYAL 阅读(767) 评论(0) 推荐(0)
摘要:描述 给若干个模式串,以及若干个句子,判断每个句子里是否包含模式串。 句子和模式串都由小写字母组成 输入第一行是整数n,表示有n个模式串 ( n <= 1000)接下来n行每行一个模式串。每个模式串长度不超过20接下来一行是整数m,表示有m个句子 (m <= 1000)接下来m行,每行一个句子,每个 阅读全文
posted @ 2018-10-29 23:15 TobicYAL 阅读(712) 评论(0) 推荐(0)