
ACM
文章平均质量分 75
LosinueriS
渴望程度是你能力的唯一限制
展开
-
【BFS】迷宫类问题
迷宫类问题:给定一个地图,一个起点和一个终点,问从起点到原创 2014-10-22 12:21:36 · 782 阅读 · 0 评论 -
【高效算法设计——二分法】UVa 1607 Gates
GatesTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionIn contemporary VLSI chip industry, the software tools used原创 2015-03-14 22:01:32 · 860 阅读 · 0 评论 -
【高效算法设计——递归】 UVa 12627 Erratic Expansion
思路:由于是求区间的红气球个数,我们可以先求sum[i]表示i到n行的红球个数,利用递归思想求解设置函数g(k,i) 表示第k小时,从i到n行的红气球个数,当i>2^k时,其实就为k-1时的情况相同,当i代码如下:#include#includeint B[35];long long tri[35];long long g(int k,int i) //第原创 2015-03-15 11:06:31 · 499 阅读 · 0 评论 -
【高效算法设计——递归】 UVa 1608 Non-boring sequences
题意:给定一段序列,如果这段序列的任意连续子序列中至少存在一个数唯一,那么这段序列就是Non-boring,否则就是boring,判定这段序列是否boring思路:如果一个数A[x]是全场唯一,那么我们只需判断A[1]~A[x-1] 和A[x+1]~A[n]是否满足要求,为什么呢?因为A[x]全场唯一,所以经过A[x]的连续字段必然是Non-boring的,所以我们可以设计一个递归函数原创 2015-03-15 11:15:23 · 637 阅读 · 0 评论 -
【高效算法设计——双向扫描】 UVa 1442 Cave
CavTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionAs an owner of a land with a cave you were delighted when yo原创 2015-03-15 11:08:43 · 971 阅读 · 0 评论 -
【集合DP】复杂状态的动态规划
首先我们来看看这样一个问题,即著名的最优配对问题对于空间里有n个点,给定n个点间的距离,将n个点两两配成n/2对,使得所有点对距离之和最小(n对于这样一个问题,我们可以知道这是一个多决策的问题,首先为第1个点作决策进行配对,然后为第2个点进行配对,因此每一个阶段的状态必然包含当前有哪些点参与配对,哪些点未参与配对,而如果将不确定个数和序号的点保存下来呢?答案是集合,我们可以利用二进制的方法原创 2015-03-05 15:25:06 · 894 阅读 · 0 评论 -
【高效算法设计】1609 Building for UN
Building for UNTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 1399 Accepted: 618 Special JudgeDescriptionThe United Nations has decided to build a原创 2015-03-07 16:25:09 · 487 阅读 · 0 评论 -
【高效算法设计】UVa120 Stack of Flapjacks
BackgroundStacks and Queues are often considered the bread and butter of data structures and find use in architecture, parsing, operating systems, and discrete event simulation. Stacks are also impo原创 2015-03-07 14:09:31 · 557 阅读 · 0 评论 -
【高效算法设计-中途相遇法】4 Values whose Sum is 0 哈希表
4 Values whose Sum is 0Time Limit: 15000MS Memory Limit: 228000KTotal Submissions: 16375 Accepted: 4748Case Time Limit: 5000MSDescriptionThe SUM problem can原创 2015-03-07 18:17:21 · 813 阅读 · 0 评论 -
【高效算法设计——问题分解】Uva11134 Fabled Rooks
Fabled RooksTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionProblem F: Fabled RooksWe would like to place n roo原创 2015-03-09 11:40:22 · 481 阅读 · 0 评论 -
【高效算法设计——等价转换】UVa 11054
Wine trading in GergoviaTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescription2006/2007 ACM International Collegiate原创 2015-03-09 12:16:35 · 584 阅读 · 0 评论 -
【高效算法设计——扫描法】Amphiphilic Carbon Molecules 极角排序
Amphiphilic Carbon MoleculesTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionShanghai Hypercomputers, the world'原创 2015-03-10 14:47:58 · 689 阅读 · 0 评论 -
【高效算法设计——滑动窗口】UVa 11572 Unique Snowflakes
题意:给定n个数,求最长的一段使得该段内没有重复数字思路:对于该类段查找问题可以采用经典的滑动窗口方法,即维护一个窗口,窗口的左右边界用两个变量L,R代表,先增加R直到出现重复数字,再增加L,再增加R,直到R达到n那么我们需要一些数据结构来存储一些数据,使得我们能在短时间内判断窗口内是否出现重复数字这里提供两种方法,第一个是经典的set,将窗口内的数字动态存储在原创 2015-03-11 22:39:22 · 803 阅读 · 0 评论 -
【高效算法设计——最大值最小问题】UVa 714 Coying Books
Copying BooksTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionBefore the invention of book-printing, it was very h原创 2015-03-11 22:53:45 · 753 阅读 · 0 评论 -
【高效程序设计——贪心】UVa 10954 优先队列
Add AllTime Limit: 3000MSMemory Limit: Unknown64bit IO Format: %lld & %lluSubmit StatusDescriptionProblem FAdd AllInput: standard inputOutput: standard output原创 2015-03-12 14:08:20 · 572 阅读 · 0 评论 -
【高效算法设计——滑动窗口】 UVa 12174 Shuffle
ShuffleTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionYou are listening to your music collection using the shuff原创 2015-03-14 22:21:11 · 860 阅读 · 0 评论 -
结构体优先队列
#include #include #include #include #include using namespace std;typedef struct { int s,e; }Node;struct cmp{ bool operator()(const Node &t1,const Node &t2) { return t1.s>t2.s; }};p原创 2014-10-03 20:24:03 · 814 阅读 · 0 评论 -
【输入】极速读取
众所周知 c++中的cin因为要保存缓冲的缘故速度比scanf慢因此 我们使用原创 2014-10-07 22:37:27 · 1041 阅读 · 0 评论 -
【RMQ】区间求最值 SOJ2436 Picture puzzle game
RMQ即范围最小值问题(Range Minimum Query)原创 2014-10-07 23:36:15 · 709 阅读 · 0 评论 -
【BFS】由八数码问题的BFS解法引出的三种BFS经典状态判重方法
问题描述:编号为0~8的原创 2014-10-23 09:35:37 · 3242 阅读 · 0 评论 -
树状数组总结篇
树状数组中用的d【】,每个点都有一定的管辖范围;如d[1]=a[1];d[2]=a[1]+a[2];d[3]=a[3];d[4]=a[1]+a[2]+a[3]+a[4];等等;这样的结构关键是为了,对一个数组内部动态的删除,增加,来高效的求某个点或者某个区间的值;比如说对数组a,改变某一位的值需O(1),求某个k区间值O(k);这样的m次操作是用O(m*k);显转载 2014-10-02 16:04:40 · 737 阅读 · 0 评论 -
【动态规划】LIS最长单调递增子序列 logn算法 并且输出子序列
#include #include #include using namespace std;const int maxN=100000;const int inf=0x3f3f3f3f;int A[maxN+50];int dp[maxN+50]; //dp[i]表示以A[i]为结尾时的长度int g[maxN+50]; //g[i]表示长度为i的LIS的最小结尾值in原创 2014-10-02 16:20:55 · 961 阅读 · 0 评论 -
SOJ 2037: Language of FatMouse
We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation has already joined the WTO. Thanks to Turing we have computers to help him.InputInput consists of up原创 2014-09-27 09:45:39 · 770 阅读 · 0 评论 -
【连续子段和被某数整除】SOJ 2293: The Longest SubSequence
You will be given a sequence consists of many numbers, your task is to calculate the length of the longest consecutive subsequence , the sum of which can be divided by another given number.Input原创 2014-10-02 22:51:44 · 1212 阅读 · 0 评论 -
【异或】SOJ Find Differences
Description给你 n*2+1 个数 其中有 n 对是一样的 让你找出单出来的那一个Input输入有多组数据每组数据第一行,是一个整数 n(1 <= n <= 1000000) 接下来 n*2+1 行,每行一个整数 (在 int 范围内)Output输出单出来的那个数Sample Input12211222Sample Output12 分析:此原创 2014-10-02 23:50:09 · 652 阅读 · 0 评论 -
【并查集】SOJ并查集篇
给出并查集模板原创 2014-10-02 17:13:42 · 807 阅读 · 0 评论 -
二维树状数组的使用
问题:一个由数字构成的大矩阵,能进行两种操作 1) 对矩阵里的某个数加上一个整数(可正可负) 2) 查询某个子矩阵里所有数字的和,要求对每次查询,输出结果。 一维树状数组很容易扩展到二维,在二维情况下:数组A[][]的树状数组定义为: C[x][y] = ∑ a[i][j], 其中, x-lowbit(x) + 1 y-lowbit(y) + 1转载 2014-10-02 15:41:54 · 615 阅读 · 0 评论 -
树状数组应用之——求逆序对
这里说的很好,把求逆序的步骤说的很明白,我也是看完才懂的,之前自己想了很久就是不明白为什么可以用树状数组求逆序 转载:树状数组,具体的说是 离散化+树状数组。这也是学习树状数组的第一题.算法的大体流程就是:1.先对输入的数组离散化,使得各个元素比较接近,而不是离散的,2.接着,运用树状数组的标准操作来累计数组的逆序数。算法详细解释:1.解释为什么要有离散的这么一个转载 2014-10-02 16:06:24 · 1691 阅读 · 0 评论 -
树状数组应用之——区间修改 点查询
Color the ballTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4258 Accepted Submission(s): 2285Problem DescriptionN个气球排成一排,从左到右转载 2014-10-02 16:08:33 · 687 阅读 · 0 评论 -
SOJ 2309: In the Army Now 树状数组求逆序对
Time Limit:1000ms Memory Limit:32768KBDescriptionThe sergeant ordered that all the recruits stand in rows. The recruits haveformed K rows with N people in each, but failed to stand原创 2014-10-01 11:24:48 · 771 阅读 · 0 评论 -
NYOJ 题目55 懒省事的小明
懒省事的小明时间限制:3000 ms | 内存限制:65535 KB难度:3描述 小明很想吃果子,正好果园果子熟了。在果园里,小明已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆。小明决定把所有的果子合成一堆。 因为小明比较懒,为了省力气,小明开始想点子了: 每一次合并,小明可以把两堆果子合并到一起,消耗的体力等于两堆果子的原创 2014-09-13 09:46:22 · 846 阅读 · 0 评论 -
【高效算法设计——跳跃枚举】Uva 11093 Just Finish it up
Just Finish it upTime Limit: 3000MSMemory Limit: Unknown64bit IO Format: %lld & %lluSubmit StatusDescription I I U P C 2 0 06Problem J: Just Finis原创 2015-03-12 14:17:33 · 624 阅读 · 0 评论