线段树
文章平均质量分 82
Roly_Yu
快码佳编
展开
-
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 · 483 阅读 · 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 · 484 阅读 · 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 · 366 阅读 · 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 · 362 阅读 · 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 · 331 阅读 · 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 · 402 阅读 · 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 · 376 阅读 · 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 · 451 阅读 · 0 评论 -
POJ 2528 Mayor's posters
因为规模比较大离散化+线段树原创 2014-09-26 23:04:19 · 444 阅读 · 0 评论