![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
martinue
攻城狮
展开
-
hdu 1394 (线段树推荐模板)
Problem DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i aj.For a given sequence of numbers a1, a2, ..., an, if we mov原创 2015-06-03 22:01:23 · 414 阅读 · 0 评论 -
hdu 1754 I Hate It(线段树)
Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N原创 2015-05-05 21:42:08 · 726 阅读 · 0 评论 -
hdu4099(trie树,斐波那契数列)
Problem DescriptionThe well-known Fibonacci sequence is defined as following: Here we regard n as the index of the Fibonacci number F(n). This sequence has been studied since the publica原创 2015-09-14 20:15:06 · 863 阅读 · 0 评论 -
谷歌2014面试题 Problem E. Spaceship Defence(spfa,哈希)
DescriptionThe enemy has invaded your spaceship, and only superior tactics will allow you to defend it! To travel around your spaceship, your soldiers will use two devices: teleporters and turbo原创 2016-06-09 13:47:40 · 430 阅读 · 0 评论 -
六大排序(选择,插入,冒泡,希尔,快排,堆排序)
1.实现简单选择排序、直接插入排序和冒泡排序。2.实现希尔排序算法。3.实现快速排序算法。4.实现堆排序算法。想想这么多排序方法,乍一看挺复杂,写起来还挺简单的……#include #include #include #include#include#include#include#includeusing namespace std;typedef lo原创 2016-06-14 18:17:19 · 1646 阅读 · 2 评论 -
hdu2825(ac自动机,状态压缩dp)
Wireless PasswordTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5524 Accepted Submission(s): 1741Problem DescriptionLiyuan lives in a old ap...原创 2016-03-16 13:50:48 · 636 阅读 · 2 评论 -
hdu4057(ac自动机,状态压缩dp)
Rescue the RabbitTime Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1790 Accepted Submission(s): 512Problem DescriptionDr. X i原创 2016-03-15 14:42:05 · 1290 阅读 · 0 评论 -
hdu4758(ac自动机,状态压缩dp)
Walk Through SquaresTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1136 Accepted Submission(s): 356Problem Description原创 2016-03-17 20:11:48 · 571 阅读 · 0 评论 -
查找的有关操作
1.利用实验一建立有序表,采用折半查找实现某一已知的关键字的查找。2.随机产生一组关键字,利用二叉排序树的插入算法建立二叉排序树,然后删除某一指定关键字元素。4.已知散列函数为H(key)=key%p(p为自定的常数),冲突处理方法分别为线性探测法、外拉链法实现散列表的建立(利用插入算法实现)。 #include #include #include #inclu原创 2016-06-14 12:32:11 · 1446 阅读 · 0 评论 -
hdu5775(2016多校第四场,线段树求逆序数)
Bubble SortTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1907 Accepted Submission(s): 484Problem DescriptionP is a permutation原创 2016-07-29 10:31:57 · 446 阅读 · 0 评论 -
物流配送系统
实现一个物流配送系统的货物分配以及运输路线的数据结构实验。从一个始发站向周围用卡车运送货物,是运送路线尽量达到最优,运送的成本(卡车数量尽量少)尽量达到最小,利用计算机完成相应计算并给出相应的送货方案。将路径问题看成一个旅行商问题,用贪心策略先求出路径,然后继续用贪心策略装货物并用车配送。#include #include#include#include#includeusi原创 2016-07-15 13:42:40 · 3782 阅读 · 0 评论 -
图论小系统
将自己学的知识整合了一下,弄了个小的图论系统。有关知识请看:http://blog.csdn.net/column/details/tulun.html#include #include #include #include#include#include#include#include#includeusing namespace std;typedef lon原创 2016-06-28 11:05:36 · 999 阅读 · 0 评论 -
hdu1698(线段树区间更新)
Problem 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 consecutive metallic sticks which are of the sa原创 2015-08-08 12:02:32 · 468 阅读 · 0 评论 -
Cutting Tree(并查集)
题意:给你一个森林,q a b操作查询a和b之间能否到达,c d操作把d和他的爸爸的边删掉。思路:并查集,所有点指向根节点,更新就行了。//#pragma comment(linker, "/STACK:102400000,102400000")#include #include#include#include#include#include#include#inclu原创 2016-10-20 20:47:23 · 375 阅读 · 0 评论 -
poj2828(线段树)
Buy TicketsTime Limit: 4000MS Memory Limit: 65536KTotal Submissions: 15869 Accepted: 7905DescriptionRailway tickets were difficult to buy around the Lunar New Y原创 2015-08-07 17:24:40 · 367 阅读 · 0 评论 -
poj1611(并查集)
Description严重急性呼吸系统综合症( SARS), 一种原因不明的非典型性肺炎,从2003年3月中旬开始被认为是全球威胁。为了减少传播给别人的机会, 最好的策略是隔离可能的患者。在Not-Spreading-Your-Sickness大学( NSYSU), 有许多学生团体。同一组的学生经常彼此相通,一个学生可以同时加入几个小组。为了防止非典的传播,NSYSU收集了所有学生团体原创 2015-08-10 14:06:35 · 338 阅读 · 0 评论 -
poj2492(加权值的并查集)
DescriptionBackgroundProfessor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of原创 2015-08-10 14:19:56 · 920 阅读 · 0 评论 -
图的有关操作
1.键盘输入数据,建立一个有向图的邻接表。2.输出该邻接表。3.在有向图的邻接表的基础上计算各顶点的度,并输出。4.以有向图的邻接表为基础实现输出它的拓扑排序序列。5.采用邻接表存储实现无向图的深度优先非递归遍历。6.采用邻接表存储实现无向图的广度优先遍历。7.在主函数中设计一个简单的菜单,分别调试上述算法。#include #include #include #原创 2016-05-22 17:21:54 · 792 阅读 · 0 评论 -
树与二叉树的常见操作
实验内容: 1.输入字符序列,建立二叉链表。 2.前序,中序,后序遍历二叉树:递归算法。 3.中序遍历二叉树:非递归算法。 4.求二叉树的高度 。 5.求二叉树的叶子个数。 6.借助队列实现二叉树的层次遍历。 7.在主函数中设计一个简单的菜单,分别调试上述算法。#include #include #incl原创 2016-04-21 13:01:50 · 599 阅读 · 0 评论 -
栈和队列的有关操作
目的要求1.掌握栈、队列的思想及其存储实现。2.掌握栈、队列的常见算法的程序实现。实验内容1.采用链式存储实现栈的初始化、入栈、出栈操作。2.采用顺序存储实现栈的初始化、入栈、出栈操作。3.采用链式存储实现队列的初始化、入队、出队操作。4.采用顺序存储实现循环队列的初始化、入队、出队操作。5.在主函数中设计一个简单的菜单,分别测试上述算法。6. 利用栈实现数原创 2016-04-14 19:43:43 · 553 阅读 · 0 评论 -
线性表的有关操作
目的要求:⑴掌握单向链表的存储特点及其实现。⑵掌握单向链表的插入、删除算法及其应用算法的程序实现。实验内容:⑴随机产生或键盘输入一组元素,建立一个带头结点的单向链表(无序)。⑵遍历单向链表。⑶把单向链表中元素逆置(不允许申请新的结点空间)。⑷在单向链表中删除所有的偶数元素结点。⑸编写在非递减有序链表中插入一个元素使链表元素仍有序的函数,并利用该函数建立一个非递减有序原创 2016-04-08 09:31:05 · 498 阅读 · 0 评论 -
hdu(kmp的应用)
Problem DescriptionHomer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I ha原创 2015-10-27 20:35:24 · 439 阅读 · 0 评论 -
AC自动机算法详解
说明转载出处:http://www.cppblog.com/mythit/archive/2009/04/21/80633.html感谢大牛的博客!!首先简要介绍一下AC自动机:Aho-Corasick automation,该算法在1975年产生于贝尔实验室,是著名的多模匹配算法之一。一个常见的例子就是给出n个单词,再给出一段包含m个字符的文章,让你找出有多少个单词在文章里出现过。要搞懂转载 2015-08-13 21:20:39 · 385 阅读 · 0 评论 -
hdu1247(trie树)
DescriptionA hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary. You are to find all the hat’s words in a dictionary. In原创 2015-08-12 15:07:43 · 417 阅读 · 0 评论 -
hdu1251(trie树)
DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分原创 2015-08-12 14:45:46 · 604 阅读 · 0 评论 -
hdu1075(trie树)
DescriptionIgnatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now原创 2015-08-12 14:36:32 · 427 阅读 · 0 评论 -
hdu1671(trie树(字典树))
DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers: 1. Emergency 911原创 2015-08-12 14:28:29 · 561 阅读 · 0 评论 -
hdu1198(并查集的应用)
DescriptionBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square has a dif原创 2015-08-10 14:52:12 · 396 阅读 · 0 评论 -
hdu1558(并查集和简单几何的结合)
DescriptionA segment and all segments which are connected with it compose a segment set. The size of a segment set is the number of segments in it. The problem is to find the size of some segment原创 2015-08-10 14:44:51 · 347 阅读 · 0 评论 -
poj1182(加权值的并查集)
Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个原创 2015-08-10 14:25:49 · 362 阅读 · 0 评论 -
leetcode 140
给定一个非空字符串s和一个包含非空单词列表的字典wordDict,在字符串中增加空格来构建一个句子,使得句子中所有的单词都在词典中。返回所有这些可能的句子。说明:分隔时可以重复使用字典中的单词。 你可以假设字典中没有重复的单词。示例 1:输入:s = "catsanddog"wordDict = ["cat", "cats", "and", "sand", "dog"原创 2019-03-17 16:39:18 · 303 阅读 · 0 评论