随笔分类 -  数据结构

摘要:Problem 2136 取糖果 Accept: 89Submit: 221Time Limit: 1000 mSecMemory Limit : 32768 KB Problem Description有N个袋子放成一排,每个袋子里有一定数量的糖果,lzs会随机选择连续的几个袋子,然后拿走这些袋子中包含最多糖果的袋子。现问你,在选择x个袋子的情况下,lzs最坏情况下,也就是最少会拿到多少个糖果?对于x取值为1到n都分别输出答案。 Input第一行一个整数T,表示有T组数据。每组数据先输入一行一个整数N(1k, 则该元素一定是某些(个)区间长度为k的区间内最大值, 所以ans[k] =min. 阅读全文
posted @ 2013-12-11 17:50 Ramanujan 阅读(279) 评论(0) 推荐(0)
摘要:我猜是哈夫曼算法。。。即贪心把当前连通分量集合中权值最小的两个连接起来,再合成一个加入集合,迭代下去。来不及交了,先贴下代码。#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;#define LL long long#define MAXN 111111int n, m, u[MAXN], v[MAXN], w[MAXN];int p, q, f[MAXN ori, noi;bool have(int &n1, int & 阅读全文
posted @ 2013-11-15 01:36 Ramanujan 阅读(318) 评论(0) 推荐(0)
摘要:HyperhuffmanTime Limit: 5 Seconds Memory Limit: 32768 KBYou might have heard about Huffman encoding - that is the coding system that minimizes the expected length of the text if the codes for characters are required to consist of an integral number of bits.Let us recall codes assignment process i... 阅读全文
posted @ 2013-11-07 18:11 Ramanujan 阅读(293) 评论(0) 推荐(0)
摘要:RMQ with ShiftsIn the traditional RMQ (Range Minimum Query) problem, we have a static array A. Then for each query (L, R) (LR), we report the minimum value among A[L], A[L + 1], ..., A[R]. Note that the indices start from 1, i.e. the left-most element is A[1].In this problem, the array A is no long. 阅读全文
posted @ 2013-11-07 16:51 Ramanujan 阅读(173) 评论(0) 推荐(0)
摘要:StarsTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 28219Accepted: 12368DescriptionAstronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to 阅读全文
posted @ 2013-11-07 15:59 Ramanujan 阅读(143) 评论(0) 推荐(0)
摘要:Balanced LineupTime Limit: 5000MSMemory Limit: 65536KTotal Submissions: 29981Accepted: 14133Case Time Limit: 2000MSDescriptionFor the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with som 阅读全文
posted @ 2013-10-28 02:35 Ramanujan 阅读(225) 评论(0) 推荐(0)
摘要:A Simple Problem with IntegersTime Limit: 5000MSMemory Limit: 131072KTotal Submissions: 50205Accepted: 14911Case Time Limit: 2000MSDescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a gi 阅读全文
posted @ 2013-10-28 02:33 Ramanujan 阅读(156) 评论(0) 推荐(0)
摘要:Ultra-QuickSortTime Limit: 7000MSMemory Limit: 65536KTotal Submissions: 35702Accepted: 12856DescriptionIn this problem, you have to analyze a particul... 阅读全文
posted @ 2013-10-27 22:44 Ramanujan 阅读(250) 评论(0) 推荐(0)
摘要:Count ColorTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 32113Accepted: 9642DescriptionChosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem. There is a very long board with length L centimeter, L is a 阅读全文
posted @ 2013-10-27 17:36 Ramanujan 阅读(196) 评论(0) 推荐(0)
摘要:Just a HookTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13742Accepted Submission(s): 6816Problem DescriptionIn the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecu 阅读全文
posted @ 2013-10-27 17:35 Ramanujan 阅读(178) 评论(0) 推荐(0)
摘要:I Hate ItTime Limit: 9000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 29361Accepted Submission(s): 11640Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每 阅读全文
posted @ 2013-10-26 23:36 Ramanujan 阅读(184) 评论(0) 推荐(0)
摘要:关于举办计算机学院大学生程序设计竞赛(2013’11)的报名通知 敌兵布阵Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 32663Accepted Submission(s): 14009Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的. 阅读全文
posted @ 2013-10-26 22:15 Ramanujan 阅读(187) 评论(0) 推荐(0)
摘要:A Simple Tree ProblemTime Limit: 3 Seconds Memory Limit: 65536 KBGiven a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0.We define this kind of operation: given a subtree, negate all its labels.And we want to query the numbers of 1's of a subtree.Inpu 阅读全文
posted @ 2013-10-26 22:12 Ramanujan 阅读(196) 评论(0) 推荐(0)