数据结构
东曦哥哥
天空才是我的极限
展开
-
初学线段树
推荐博客链接:https://www.cnblogs.com/TheRoadToTheGold/p/6254255.html线段树:实质上就是一颗二叉搜索树,存储了一个区间的信息。(很容易想到用数组去存)树的每个节点都用结构体存储:区间的左右端点,区间和,懒标记。基本思想:二分。 线段树结构一般为:由上图可得,1、每个节点的左孩子区间范围为[l,mid],右孩子为[mi...转载 2019-01-22 10:51:46 · 108 阅读 · 0 评论 -
洛谷1160(链表)
题目链接:https://www.luogu.org/problem/P1160#include<bits/stdc++.h>using namespace std;bool vis[100003];list<int> s;list<int>::iterator pos[100003];int main(){ int n; scanf("%d...原创 2019-10-06 15:20:42 · 610 阅读 · 0 评论 -
洛谷1540(队列)
题目链接:https://www.luogu.org/problem/#include<iostream>#include<bits/stdc++.h>using namespace std;bool iq[100003];queue<int> memory;int main(){ int m,n; scanf("%d%d",&a...原创 2019-10-06 15:36:38 · 311 阅读 · 0 评论 -
洛谷1739(栈)
题目链接:https://www.luogu.org/problem/P1739#include<bits/stdc++.h>using namespace std;stack<bool> brackets;char s[257];int main(){ scanf("%s",s); bool flag=true; for(int i=0;s[i]!='...原创 2019-10-06 15:52:15 · 215 阅读 · 2 评论 -
洛谷1305(二叉树)
题目链接:https://www.luogu.org/problem/P1305#include<bits/stdc++.h>using namespace std;struct node{ int lch=-1; int rch=-1;};bool vis[29],isnotroot[29];char s[5];node tree[29];void build...原创 2019-10-06 20:50:01 · 139 阅读 · 0 评论 -
hdu1053(哈夫曼编码)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1053题意是,给出一排字符串,要求求出字符的8位编码的长度,哈夫曼编码值,以及之间的比值因为仅仅只要求求出哈夫曼编码值,所以不用建立哈夫曼树,可以建立优先队列,只要将每次最小的出队的两个元素合成一个新的大数,然后放进优先队列中,直到只剩下一个元素为止,那个元素就是哈夫曼编码值。注意只有一...原创 2019-10-08 16:15:19 · 202 阅读 · 0 评论