数据结构
文章平均质量分 73
Roly_Yu
快码佳编
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hdu(4339)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4339s1[i]与s2[i]匹配,树状数组i位置更新1,否则更新0#include#include#include#includeusing namespace std;const int maxn = 1000005;int c[maxn];char s1[maxn],s2[maxn]原创 2014-03-13 14:16:45 · 610 阅读 · 0 评论 -
hoj (2275)树状数组
http://acm.hit.edu.cn/hoj/problem/view?id=2275这题是树状数组的简单应用,树状数组果然是一个优秀的数据结构。#include#include #include#define maxn 50005using namespace std;const int m=32771;int n;int a[maxn],c[m原创 2014-03-13 14:15:28 · 550 阅读 · 0 评论 -
Codeforces Round #256 (Div. 2) D. Multiplication Table
#include #include #include #include #include #include #include using namespace std;typedef long long ll;int main(){ // freopen("in.txt","r",stdin); ll n,m,k; while(cin>>n>>m>>原创 2014-08-05 14:18:36 · 492 阅读 · 0 评论 -
hdu(1166)敌兵布阵
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1166这题可以用树状数组来做,也可以用线段树来做,不过线段树虽然功能强大,但是代码量大.树状数组:#include#include#include#define MAX 50005using namespace std;char str[4][6] ={"Query","Ad原创 2014-03-13 14:14:56 · 579 阅读 · 0 评论 -
hdu 1754 I Hate It
#include #include #define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn = 200005;int tree[maxn<<2];char str[10];void PushUp(int rt){ tree[rt] = max(tree[rt<原创 2014-09-25 10:56:16 · 394 阅读 · 0 评论 -
POJ 2828 Buy Tickets
#include #include #define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn = 200004;int pos[maxn];int val[maxn];int tree[maxn<<2];void PushUp(int rt){ tree[rt]原创 2014-09-21 22:29:25 · 451 阅读 · 0 评论 -
hdu 5023 A Corrupt Mayor's Performance Art
#include #include #define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn = 1100005;int tree[maxn<<2];int flag[maxn<<2];void PushUp(int rt){ tree[rt] = tree[原创 2014-09-21 21:29:48 · 541 阅读 · 0 评论 -
POJ 2528 Mayor's posters
因为规模比较大离散化+线段树原创 2014-09-26 23:04:19 · 512 阅读 · 0 评论 -
hdu 1394 Minimum Inversion Number
题意:#include #include #include #define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn = 5005;int a[maxn];int tree[maxn<<2];void PushUp(int rt){ tree[rt]原创 2014-09-25 20:39:12 · 450 阅读 · 0 评论 -
hdu 2795 Billboard
#include #include #define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn = 200005;int tree[maxn<<2];int h,w,n;void PushUp(int rt){ tree[rt] = max(tree[rt<<1]原创 2014-09-22 22:17:07 · 469 阅读 · 0 评论 -
POJ 2886 Who Gets the Most Candies?
#include #include #define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn = 500005;int tree[maxn << 2];struct child{ char name[20]; int card;}cc[maxn];vo原创 2014-09-22 17:32:23 · 557 阅读 · 0 评论 -
hdu(4325)
离散化+树状数组#include#include #include#includeusing namespace std;const int maxn = 100005;int n,m;int hash[maxn*2];int c[maxn*2];struct node{ int num; int id; friend原创 2014-03-13 14:15:35 · 569 阅读 · 0 评论 -
hdu(1053)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1053霍夫曼编码的题目,要注意n==1时的特殊情况。#include#includeusing namespace std;const int inf = 1000000;typedef struct hufcode{ int weight; int parent原创 2014-03-13 14:16:05 · 564 阅读 · 0 评论 -
hdu(4514)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4514这道题是一个带权并查集的题目。 #include #include #include using namespace std;const int maxn = 100005;int father[maxn];int rank[maxn];int weight[maxn原创 2014-03-13 14:16:24 · 680 阅读 · 0 评论 -
poj(1988)
题目:http://poj.org/problem?id=1988带权并查集的题目。//father[x] 为x的父亲节点(x所在stack顶端的cube)//weight[x] 为x所在stack包含的cube数量// up[x] 为在x上方的cube的数量// 则x之下的cube数应为weight[find(x)]-up[x]-1//即用x的父亲节点所在stack的cube数原创 2014-03-13 14:16:26 · 606 阅读 · 0 评论 -
hdu(4267)A Simple Problem with Integers(三维树状数组)
这道题拿过来感觉很蒙 , 因为以前做的都是点更新询问区间 , 或是区间更新询问点 , 这道题是在[a,b]区间内隔k个数更新一次( (i - a) % k == 0即i%k==a%k), 对于树状数组来说按照一维的方式定义, 后面在加上两维 c[i][k][i%k] (a#include #include #include string>#include string.h原创 2014-03-14 17:21:34 · 497 阅读 · 0 评论 -
POJ(2481)Cows 树状数组
#include #include #include string>#include string.h>#include #include #include #include #include #include #include #include #include using namespace std ;const int maxn = 1原创 2014-03-14 17:21:44 · 517 阅读 · 0 评论 -
POJ(2761)Feed the dogs (树状数组+离散化+贪心)
#include #include #include #include string>#include string.h>#include #include #include #include #include #include #include set>using namespace std ;const int maxn = 100002;原创 2014-03-14 17:21:49 · 558 阅读 · 0 评论 -
hdu(4339)树状数组+二分查找
/* s1[i]与s2[i]匹配,树状数组i位置更新1,否则更新0。*/#include#includestring.h>#include#includeusing namespace std;const int maxn = 1000005;int c[maxn];char s1[maxn],s2[maxn];int min(int a,int b原创 2014-03-14 17:21:21 · 528 阅读 · 0 评论 -
hdu (2852) KiKi's K-Number
二分+树状数组动态的寻找比a大k的数#include #include #include string>#include string.h>#include #include #include #include #include using namespace std;const int maxn = 100005;int c[maxn];i原创 2014-03-14 17:21:27 · 515 阅读 · 0 评论 -
hdu(1082)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1082#include#include#include#include#includeusing namespace std;struct Node{ int r,c;};map<<spanstyle="color: #8e2160">char,Node>原创 2014-03-13 14:16:07 · 582 阅读 · 0 评论 -
hdu(1515)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1515#include #include#include #include #include using namespace std;string a,b;int len;stackbuild;vectoroper;void dfs(int push,int原创 2014-03-13 14:16:10 · 760 阅读 · 0 评论 -
Hdu(4417)Super Mario
题目:http://acm.hdu.edu.cn/showproblem.php?pid=44172012成都网络赛1008 #include#include#include#includeusing namespace std;const int MAXN=100010;int c[MAXN];int n;int lowbit(int x){原创 2014-03-13 14:15:48 · 480 阅读 · 0 评论 -
POJ 3468 A Simple Problem with Integers
#include #include #define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;typedef long long ll;const int maxn = 100005;ll tree[maxn<<2];ll flag[maxn<<2];void PushUp(int rt) {原创 2014-09-26 20:20:28 · 430 阅读 · 0 评论
分享