
数据结构
L-qf
这个作者很懒,什么都没留下…
展开
-
树状数组的一维和二维模板模板
int lowbit(int x){ return x & (-x);// 返回 X 的二进制数表示为1的最低位的权值}void modify(int x,int add)//一维{ while(x<=MAXN) { a[x]+=add; x+=lowbit(x); }}int ...原创 2018-04-12 14:49:42 · 138 阅读 · 0 评论 -
HDU-2545树上战争(找根节点)
题目信息:http://acm.hdu.edu.cn/showproblem.php?pid=2545#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;struct pine { double s,e;...原创 2018-08-24 15:41:35 · 320 阅读 · 0 评论 -
HDU-2539 点球大战(字符串处理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2539#include<cstdio>#include<iostream>#include<cstring>using namespace std;int main() { int n,sum; string s1[105]; while(~sca...原创 2018-08-23 19:41:26 · 279 阅读 · 0 评论 -
HDU-1022Train Problem I(栈的简单应用)
题目信息:http://acm.hdu.edu.cn/showproblem.php?pid=1022代码:#include<iostream>#include<cstdio>#include<stack>#include<cstring>#include<algorithm>using namespace std;...原创 2018-08-13 20:25:00 · 146 阅读 · 0 评论 -
动物统计加强版【字典树】
题目信息:题目描述在美丽大兴安岭原始森林中存在数量繁多的物种,在勘察员带来的各种动物资料中有未统计数量的原始动物的名单。科学家想判断这片森林中哪种动物的数量最多,但是由于数据太过庞大,科学家终于忍受不了,想请聪明如你的ACMer来帮忙。输入第一行输入动物名字的数量N(1<= N <= 4000000),接下来的N行输入N个字符串表示动物的名字(字符串的长度不超过10,字...原创 2018-08-05 09:09:54 · 161 阅读 · 0 评论 -
KMP 字符串匹配 Binary String Matching
题目信息:题目描述Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as a substring of B? For example, the text string B is ‘10011101...原创 2018-08-04 19:55:00 · 136 阅读 · 0 评论 -
畅通工程1
题目链接:http://xyoj.xynu.edu.cn/problem.php?id=1382并查集#include<cstdio>#include<cstring>#define N 1005using namespace std;int f[N];void init() { for(int i=1; i<N; i++) f[i]=i;...原创 2018-08-04 11:37:02 · 324 阅读 · 0 评论 -
二叉链表存储的二叉树
题目信息:http://xyoj.xynu.edu.cn/problem.php?id=1367#include<stdio.h>#include<string.h>#include<stdlib.h>char s[105];typedef struct BiTNode { char data; struct BiTNode *lchild,*...原创 2018-08-04 10:14:21 · 1264 阅读 · 0 评论 -
出栈序列统计
题目链接:http://xyoj.xynu.edu.cn/problem.php?id=1330递归+模拟#include<iostream>#include<cstdio>using namespace std;int ans;void dfs(int in,int out) { if(out==0) ans++; else if(in==0)...原创 2018-08-04 10:13:04 · 696 阅读 · 0 评论 -
HDU-2527 Safe Or Unsafe(哈夫曼树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2527#include<cstdio>#include<iostream>#include<cstring>#include<queue>using namespace std;int main() { priority_queue<...原创 2018-08-21 20:24:59 · 283 阅读 · 0 评论