
acm_数据结构
文章平均质量分 60
小七和小墨
http://blog.youkuaiyun.com/ccsu_cherish
http://blog.youkuaiyun.com/shahdza/article/details/6632538
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
acm之并查集
为了解释并查集的原理,我将举一个更有爱的例子。话说江湖上散落着各式各样的大侠,有上千个之多。他们没有什么正当职业,整天背着剑在外面走来走去,碰到和自己不是一路人的,就免不了要打一架。但大侠们有一个优点就是讲义气,绝对不打自己的朋友。而且他们信奉“朋友的朋友就是我的朋友”,只要是能通过朋友关系串联起来的,不管拐了多少个弯,都认为是自己人。这样一来,江湖上就形成了一个一个的群落,通过两两之间的朋友转载 2013-07-16 10:56:12 · 732 阅读 · 0 评论 -
hdu1050 Moving Tables BIT树状数组
The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a plan to reform its system. The reform includes moving a lot of tables between rooms. Becau原创 2013-12-22 20:31:05 · 718 阅读 · 0 评论 -
STL Map详解
文章出处:http://blog.youkuaiyun.com/q3498233/article/details/4400992关于STL中map的用法剖析【完整版】1 map概述 STL(Standard Template Library 标准模版库)是C++标准程序库的核心,它深刻影响了标准程序库的整体结构。STL是一个范型(generic)程序库,提供一系列软件转载 2013-12-14 21:24:37 · 675 阅读 · 0 评论 -
hdu1800 Flying to the Mars ELFHash/BKDHash
we assume that one soldier has one level number indicating his degree. The soldier who has a higher level could teach the lower , that is to say the former’s level > the latter’s . But the lower can’t原创 2013-12-05 16:28:50 · 697 阅读 · 0 评论 -
hdu1496 Equations Hash
Consider equations having the following form: a*x1^2+b*x2^2+c*x3^2+d*x4^2=0a, b, c, d are integers from the interval [-50,50] and any of them cannot be 0.It is consider a solution a system (原创 2013-12-03 16:49:26 · 653 阅读 · 0 评论 -
hdu4432 Sum of divisors
题目:mmm is learning division, she's so proud of herself that she can figure out the sum of all the divisors of numbers no larger than 100 within one day!But her teacher said "What if I ask you to giv原创 2013-11-01 17:20:17 · 738 阅读 · 0 评论 -
第九届湖南省大学生程序设计竞赛H题 高桥,低桥(UVA 12663) BIT 树状数组
There are one high bridge and one low bridge across the river. The river has flooded twice, why the high bridge is flooded twice but the low bridge is flooded only once?A: Because the lower bridge i原创 2013-10-22 11:58:07 · 1335 阅读 · 0 评论 -
vijos1514 天才的记忆 线段树
题解:题目意思很明确,就是查询串的区间最值,利用线段树可以便捷的解出。要注意的是在query查询的时候,初始值ret最好是设为大负数比如-(1#include#include#include#include#include#define maxn 200002#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using name原创 2013-10-08 21:42:55 · 718 阅读 · 0 评论 -
poj3061 Subsequence 尺取法
A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal length of the s原创 2013-10-03 20:04:19 · 683 阅读 · 0 评论 -
poj2431 Expedition 优先队列
group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately managed to run over a rock and puncture the truck's fuel tank. The原创 2013-09-07 16:15:32 · 957 阅读 · 0 评论 -
并查集的两种优化(按秩合并,路径压缩)
并查集是建立在对不相交集合进行的两种基本操作的基础之上的。操作之一:检索某元素属于哪个集合;操作之二:合并两个集合。黑书上说了,这种结构显然可以用链表或森林实现,显然用链表进行查询时间复杂度应该是O(n)级别的,而使用森林进行查访如果处理的好时间复杂度就应该是O(logn)。对于用森林来实现并查集,黑书上有句加点话我同样认为很重要“用树根来标识一个集合”。于是对于并查集就存在这么两个很关键的优化操原创 2013-08-04 22:14:55 · 11040 阅读 · 0 评论 -
hdu1285 确定比赛名次 拓扑排序
题目是要求为一场比赛写出成绩排名。这题需要用到拓扑排序。拓扑排序是对于有向无环图,对于所有入度为0的点入队列,因为这样的顶点表示没有事件可以依赖。将所有入度为0的点入队列后,依次将它所值得点入度减1,并将新的入度为0的点入队。循环过后便用bfs实现了拓扑排序。要注意的两点:一是根据题目要求要使用优先队列。二是在输入的时候一定要判断是否有重边。#include#include#inc原创 2013-08-02 22:14:25 · 534 阅读 · 0 评论 -
ccsu 1630卧底 并查集
YY最近刚从警校毕业,从小一身浩然正气,一次他参加到了一次警匪的抓捕活动,现在他想知道是否双方当中存在着卧底,所以YY只能从在混战当中的打斗来进行判断,现在人员被编号为1-n号n个人物,请你帮帮他判断是否有卧底存在。Input 第一行输入测试数据组数. 第二行输入n,m.表示现在有n个人,m次攻击 接下来m行,输入形式为u,v.表示u,v相互攻击 Output输原创 2013-07-16 17:25:06 · 649 阅读 · 0 评论 -
hdu 1232畅通工程 并查集
并查集思想详见转载#include#include#include#include#include#includeusing namespace std;int pre[1001];//pre[i]的上级。int find(int k){ int i=k; while(pre[i]!=i) { i=pre[i]; }//查找最终原创 2013-07-16 10:51:29 · 669 阅读 · 0 评论 -
Codeforces Round #223 (Div. 2) B 哈希表
题意:说得是一串数列。如果按照题目所示的排列。那么就是一个 stairsSequence a1, a2, ..., a|a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≤ i ≤ |a|), that the following condition is met:a1原创 2014-01-13 17:40:48 · 771 阅读 · 0 评论