![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
算法-基础数据结构
介绍基础数据结构题目
哦摩西罗伊
这个作者很懒,什么都没留下…
展开
-
poj 1611
Description严重急性呼吸系统综合症( SARS), 一种原因不明的非典型性肺炎,从2003年3月中旬开始被认为是全球威胁。为了减少传播给别人的机会, 最好的策略是隔离可能的患者。在Not-Spreading-Your-Sickness大学( NSYSU), 有许多学生团体。同一组的学生经常彼此相通,一个学生可以同时加入几个小组。为了防止非典的传播,NSYSU收集了所有学生原创 2015-08-09 16:26:49 · 351 阅读 · 0 评论 -
Huffman树的创建及编码
直接上代码:#include #include #include #define inf 99999999struct HuffmanNode{ int weight; int lchild,rchild,parent;};void Select(struct HuffmanNode *p,int n,int& num1,int& num2){ int i; in原创 2016-05-05 12:29:42 · 410 阅读 · 0 评论 -
树的基本操作
没啥好说的,就是一些树的基本操作诶。#include #include #define Max_Size 100struct Binode{ char res; struct Binode *lchild,*rchild;};struct Binode* First_Creat_Bitree(){//建立一棵二叉树 char ch; struct Binode *p原创 2016-05-05 12:24:31 · 402 阅读 · 0 评论 -
单链表的基本操作
也就是一些关于单链表的基本操作,不多说上代码:#include #include struct node{int res;struct node *next;};struct node *Creat_link_list(int n){//用尾插法建立一个带有头结点的单链表 struct node *head,*p,*q; int i; q=head=(struct node原创 2016-04-09 13:43:51 · 593 阅读 · 0 评论 -
线段树的入门级
线段树是一种二叉搜索树,与区间树相似,它将一个区间划分成一些单元区间,每个单元区间对应线段树中的一个叶结点。 对于线段树中的每一个非叶子节点[a,b],它的左儿子表示的区间为[a,(a+b)/2],右儿子表示的区间为[(a+b)/2+1,b]。因此线段树是平衡二叉树,最后的子节点数目为N,即整个线段区间的长度。 使用线段树可以快速的查找某一个节点在若干条线段中出现的次数转载 2015-09-15 19:30:24 · 223 阅读 · 0 评论 -
hdu 1754
Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0原创 2015-09-15 20:39:05 · 250 阅读 · 0 评论 -
hdu 1285 邻接表数组实现
相比邻接矩阵,邻接表的拓扑排序麻烦在判断重边上,但邻接表节省内存和时间,是一个很不错的方法。#include #include using namespace std;int u[1100],v[1100],indegree[510],first[1100],next0[1100];int main(){ int n,m; while(cin>>n>>m) {原创 2015-09-10 21:15:41 · 282 阅读 · 0 评论 -
简单的拓扑排序模板
拓扑排序一.定义 对一个有向无环图(Directed Acyclic Graph简称DAG)G进行拓扑排序,是将G中所有顶点排成一个线性序列,使得图中任意一对顶点u和v,若 ∈E(G),则u在线性序列中出现在v之前。 通常,这样的线性序列称为满足拓扑次序(Topological Order)的序列,简称拓扑序列。 注意: 1)只有有向无环图才存在拓扑序列;转载 2015-09-09 19:38:23 · 437 阅读 · 0 评论 -
hdu 1285
确定比赛名次Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17820 Accepted Submission(s): 7132Problem Description有N个比赛队(1 Input原创 2015-09-09 20:15:56 · 303 阅读 · 0 评论 -
hdu 1558
A 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 set.原创 2015-08-10 14:57:12 · 235 阅读 · 0 评论 -
poj 1182
食物链Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 31929 Accepted: 9326Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物转载 2015-08-10 12:06:16 · 207 阅读 · 0 评论 -
HDU 1198
Farm Irrigation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4962 Accepted Submission(s): 2130原创 2015-08-10 11:59:50 · 235 阅读 · 0 评论 -
hdu 1198
Farm Irrigation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4962 Accepted Submission(s): 2130原创 2015-08-10 12:07:52 · 276 阅读 · 0 评论 -
hdu 1829
BackgroundProfessor 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 the opposite gend原创 2015-08-09 16:34:23 · 287 阅读 · 0 评论 -
栈和队列的有关操作
直接上代码:#include #include #define Stack_Init_Size 100#define Max_Size 100struct node { int res; struct node *next;};struct node *Init_List_Stack(){ //对链栈的初始化,进栈,出栈操作 struct nod原创 2016-04-24 10:10:17 · 289 阅读 · 0 评论