ST 时间限制:1000 ms  |  内存限制:65535 KB 难度:1 描写叙述 "麻雀"lengdan用随机数生成了后台数据.可是笨笨的他被妹纸的问题给难住了. .. 已知lengdan生成了N(1=<N<=10005)个随机整数,妹子对这些数可能有下面几种操作或询问: 1,A a b c 表示给区间a到b内每一个数都加上c. 2,S a b  表示输出区间a到b内的和. 3,Q a b 表示区间a到b内的奇数的个数: 为了使妹纸不口渴,所以我们决定妹纸的询问次数少…
意甲冠军:一个典型的段树C,Q问题,有n的数量a[i] (1~n),C, a, b,c在[a,b]加c Q a b 求[a,b]的和. #include<cstdio> #include<stdlib.h> #include<string.h> #include<string> #include<map> #include<cmath> #include<iostream> #include <queue> #…
解决报告 意甲冠军: 一定长度8000段染.寻求染色完成后,.. 思路: 区间问题用线段树.成段的更新区间.最后把全部的区间下压到叶子结点,统计叶子结点的颜色. #include <iostream> #include <cstring> #include <cstdio> using namespace std; int lz[32000],_hash[10000],color[10000],cnt; void push_down(int rt) { if(lz[rt…
You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval. Input The firs…
Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 34522   Accepted: 16224 Case Time Limit: 2000MS Description For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer Joh…
B - 单点更新2 Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.  这让很多学生很反感.  不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问.当然,老师有时候需要更新某位同学的成绩. Input 本题目包含多组测试,请处理到文件结束.  在…
HDU1698.Just a Hook 这个题是最最基础的成段更新的线段数的题目,直接贴代码吧. 代码: #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<algorithm> #include<cstdlib> #include<queue> #include<stack> #include<ma…
POJ 3468.A Simple Problem with Integers 这个题就是成段的增减以及区间查询求和操作. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<algorithm> #include<queue> #include<map> usi…
POJ3225.Help with Intervals 这个题就是对区间的各种操作,感觉这道题写的一点意思都没有,写到后面都不想写了,而且更神奇的是,自己的编译器连结果都输不出来,但是交上就过了,也是令人头大的操作,这题没意思,不要写了.我写到后面就写不下去了,直接去看了别人的代码... 代码: #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<…
POJ2528.Mayor's posters 这道题真的是线段数的经典的题目,因为数据很大,直接建树的话肯定不可以,所以需要将数据处理一下,没有接触离散化的时候感觉离散化这个东西相当高级,其实在不知道离散化是什么东西之前,就已经用过这种东西了,只是不知道叫什么.关于离散化,就是根据数的相对大小对他们进行映射,用小的数来表示他们.所以要先排序,然后去重,然后操作就可以.有排序版的离散化和STL版的离散化(自己起的名字 ...),代码里写的是排序版的,就是for循环遍历的时候,和身边的数比较一下是…