线段树
文章平均质量分 66
诺诺罗亚
固执!!!!!!!!!
展开
-
HDU 2795 Billboard
题意 有一个l*w的木板,给n个1*xi的木板,每次都放到最上边且最左边! 思路 找到比xi大的,且最上边的木板。 注意 l*w的木板,有l和w开数组 都会爆掉!!!而w太大没什么用 所以当w>n‘时 w=n; 附AC代码 #include #include #define LL(x) (x<<1) #define RR(x) (x<<1)|1 #include u原创 2014-12-02 21:51:12 · 302 阅读 · 0 评论 -
POJ 2828 Buy Tickets
题意:N个人插队,每一个人会给你他要插到第几个位置,和他的价值;输出最后的顺序; 思路:逆序,按照空位确定位置!!! 附AC代码 #include #include using namespace std; int tree[200000*4]; struct node{ int tot,v; }num[200000]; int ans[200000]; void bulid(int l,原创 2014-12-04 21:45:06 · 325 阅读 · 0 评论 -
poj 2528 离散化+线段树
这个破题 我WA 了 我实在找不到我那里错了 题意:有一个墙,往墙上贴报纸,最后问能看到几张报纸 其实就是很容易的线段树,不容易的地方在于离散化 离散化要保存所有需要用到的值,排序后,分别映射到1~n,这样复杂度就会小很多很多这题的难点在于每个数字其实表示的是一个单位长度(并且一个点),这样普通的离散化会造成许多错误(包括我以前的代码,这题数据奇弱) 出下面两个简单的例子应该能体现普通原创 2015-01-12 15:56:59 · 474 阅读 · 0 评论 -
HDU 1698 Just a hook 线段树(段更新,段询问)
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. 线段树段更新!!!原创 2014-12-08 18:20:42 · 335 阅读 · 0 评论 -
POJ 3468 A Simple Problem with Integers 线段树
感觉没什么好说的 就是简单地成段更新,还有区间询问!!! 附AC代码 #include #include #include #include using namespace std; long long tree[111111*4],lazy[111111*4]; void fun(int i,int x) { if(lazy[i]!=0) { lazy[i*2]+=lazy[原创 2014-12-08 20:51:53 · 285 阅读 · 0 评论 -
zoj 3471状态压缩DP
#include #include int max(int a,int b) { if(a>b) return a; return b; } int dp[100000],map[15][15],mark[15]; int main() { int i,j,n,m,k; while(scanf("%d",&n)!=EOF&&n) { for(i=1;i<=n;i++) for原创 2015-01-23 21:36:19 · 534 阅读 · 0 评论