POJ 2828 单点更新(好题)】的更多相关文章

Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 15086   Accepted: 7530 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue… The Lunar New Year wa…
当初听郭炜老师讲时不是很懂,几个月内每次复习树状数组必看的题 树的dfs序映射在树状数组上进行单点修改,区间查询. /* 树状数组: lowbit[i] = i&-i C[i] = a[i-lowbit[i]+1]+...+a[i] 求和: 设sum[k] = a[1]+a[2]+...+a[k] 则a[i]+a[i+1]+...+a[j] = sum[j]-sum[i-1] 在树状数组上:sum[k] = C[n1]+C[n2]+...+C[k] n1 = n2-lowbit[n2]... &g…
Apple Tree Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u Java class name: Main [Submit] [Status] [Discuss] Description There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the…
Mobile phones Time Limit: 5000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u Java class name: Main [Submit] [Status] [Discuss] Description Suppose that the fourth generation mobile phone base stations in the Tampere area operate a…
敌兵布阵 单点更新和区间更新还是有一些区别的,应该注意! [题目链接]敌兵布阵 [题目类型]线段树单点更新 &题意: 第一行一个整数T,表示有T组数据. 每组数据第一行一个正整数N(N<=50000),表示敌人有N个工兵营地,接下来有N个正整数,第i个正整数ai代表第i个工兵营地里开始时有ai个人(1<=ai<=50). 接下来每行有一条命令,命令有4种形式: (1) Add i j,i和j为正整数,表示第i个营地增加j个人(j不超过30) (2)Sub i j ,i和j为正整数…
Brainman Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10575   Accepted: 5489 Description BackgroundRaymond Babbitt drives his brother Charlie mad. Recently Raymond counted 246 toothpicks spilled all over the floor in an instant just b…
题目传送门 /* 结点存储下面有几个空位 每次从根结点往下找找到该插入的位置, 同时更新每个节点的值 */ #include <cstdio> #define lson l, m, rt << 1 #define rson m+1, r, rt << 1 | 1 + ; int pos[MAX_N], val[MAX_N]; ]; int que[MAX_N]; int id; void build(int l, int r, int rt) { sum[rt] = r…
POJ 2828 还是弱啊.思维是个好东西... 刚开始想来想去用线段树存人的话不仅超时,而且存不下...居然是存空位! sum[]数组存这个序列空位个数,然后逆序遍历.逆序好理解,毕竟最后一个人插进来位置已经可以确定了,前面的位置就根据他来更新. #include<iostream> #include<cstdio> #define mid int m=(l+r)>>1 #define lson l,m,rt<<1 #define rson m+1,r,r…
题目链接 Description During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except the two at the ends, every village…
敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 87684    Accepted Submission(s): 36912 Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务…