【序列操作III】线段树
题目描述
给出序列 a1,a2,…an(0≤ai≤109),有关序列的四种操作:
1. al,al+1,…,ar(1≤l≤r≤n)加上 x(-103≤x≤103)
2. al,al+1,…,ar(1≤l≤r≤n)乘上 x(-103≤x≤103)
3. al,al+1,…,ar(1≤l≤r≤n)变成 x-al,x-al+1 ,…,x-ar(-103≤x≤103)
4. 求:
aaarticlea/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAA4AGQDAREAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+/igAoAKAPxa+Pf8Aw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WH5aMXyqV/D9c/ZrsNd1rVtab43ftIaU2q6heag2maH8avEum6Lp7XdxLObPSdNiRorDT7cyeVZ2cZMdvbpFCh2oCeWjSVClCkp1aqhFR9pWqSqVZWv706kvelJ9ZPXbXc6ak/aTlNxpwuorlpwUILlio3jBaJyteXeTb0bue4+GfD0PhjQdH0JNT1vXTo9ilhHrfifU5ta8SX0asrNPqus3IFzf3UzIjTzy4aQrGWGUGeqrVdWbnyU6d4UYONGCpwfsKSpQk4p2c5LmnOTu5ValWbfNKTfNRpKjBw9pUqXqV6nNWm6k061apVcFJ6qnDmVOjDanRhSpq6jr5h8QPgdafELxB/wkE3xU+N3hB/sVtYnSfh/8Udd8KeHyLdpiLv+ybFXgF7P5uLm5GHmWOEOMpuPLTpKlPETVSrP29WNVxqVHOFLlo0aPJh4t/uqUlS9rKmm061StUupTZ0zqc8KUOSnH2UJQUoQUZ1E6tSrzVZJ3qTXPyRlLVUo06d2oJnW/Dv4eW3w60a60WLxd498arc6k2pjUviP4tv/ABhrNtI1vb24tbPUdRUS21jGIBNFaINkdxLczK2+WQ10yqc0KMOSlH2KmlUhTUas+dzu6k07zajOVOLe1KTp6xcr88aajOrPnqS9qqUXTlNulH2UpSi4U3pGTk1Kb3lKNN3vFM75Ioo2leOONHmYPM6IqtK6okavKwAMjLHGiBnLMEVEB2qM5rRWWiu3ZbXe7tfd9Xu+rb1NPPytfyTbS9Ltu2123q2230AFABQB/9k=" alt="" />
(即求:al+al+1+al+2+…+ar(1≤l≤r≤n)
所有操作均模 109+7
输入格式
第一行包含两个数 n(1≤n≤105)和 m(1≤m≤105),表示序列长度和操作次数
接下来一行包含 n 个数,空格隔开,表示 a1,a2,…,an 。
接下来 m 行,每行为以下 4 种格式之一:
- 0 l r x ,表示 al,al+1,…,ar 加上 x
- 1 l r x ,表示 al,al+1,…,ar 乘上 x
- 2 l r x ,表示 al,al+1,…,ar(1≤l≤r≤n)变成x-al,x-al+1 ,…,x-ar 。
- 3 l r ,求:
aaarticlea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qus3IFzf3UzIjTzy4aQrGWGUGeqrVdWbnyU6d4UYONGCpwfsKSpQk4p2c5LmnOTu5ValWbfNKTfNRpKjBw9pUqXqV6nNWm6k061apVcFJ6qnDmVOjDanRhSpq6jr5h8QPgdafELxB/wkE3xU+N3hB/sVtYnSfh/8Udd8KeHyLdpiLv+ybFXgF7P5uLm5GHmWOEOMpuPLTpKlPETVSrP29WNVxqVHOFLlo0aPJh4t/uqUlS9rKmm061StUupTZ0zqc8KUOSnH2UJQUoQUZ1E6tSrzVZJ3qTXPyRlLVUo06d2oJnW/Dv4eW3w60a60WLxd498arc6k2pjUviP4tv/ABhrNtI1vb24tbPUdRUS21jGIBNFaINkdxLczK2+WQ10yqc0KMOSlH2KmlUhTUas+dzu6k07zajOVOLe1KTp6xcr88aajOrPnqS9qqUXTlNulH2UpSi4U3pGTk1Kb3lKNN3vFM75Ioo2leOONHmYPM6IqtK6okavKwAMjLHGiBnLMEVEB2qM5rRWWiu3ZbXe7tfd9Xu+rb1NPPytfyTbS9Ltu2123q2230AFABQB/9k=" alt="" />
输出格式
对于每次询问,输出单独一行表示答案。
样例数据 1
输入
5 4
1 2 3 4 5
0 1 5 1
1 1 5 -1
2 1 5 1
3 5 5
输出
7
题目分析
同样是线段树裸题。维护区间加、乘标记,对于操作3,先乘-1,再加上x。
坑点同样是下标下放顺序:先乘后加,乘的时候add标记可以直接乘,而加的时候乘号标记必须已经下放。
code
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std; const int N = 1e5 + , Mod = 1e9 + ;
typedef long long ll;
int n, m, data[N];
struct node{
int len;
ll sum, add, time;
node():sum(), time(), len(), add(){}
}; namespace SegTree{
node tr[N << ];
inline void upt(int k){
tr[k].sum = (tr[k << ].sum + tr[k << | ].sum) % Mod;
}
inline void build(int k, int l, int r){
tr[k].len = r - l + ;
if(l == r){
tr[k].sum = data[l];
tr[k].add = , tr[k].time = ;
return;
}
int mid = l + r >> , lc = k << , rc = k << | ;
build(lc, l, mid);
build(rc, mid + , r);
upt(k);
}
inline void Add(int , int);
inline void plus(ll &x, ll v){
x = (x + v) % Mod;
while(x < ) x += Mod;
}
inline void mul(ll &x, ll v){
x = (x * v) % Mod;
while(x < ) x += Mod;
}
inline void Time(int k, int v){
mul(tr[k].add , v);
mul(tr[k].sum , v);
mul(tr[k].time , v);
}
inline void Add(int k, int v){
plus(tr[k].sum, 1LL * tr[k].len * v);
plus(tr[k].add, v);
}
inline void pushDown(int k){
int lc = k << , rc = k << | ;
if(tr[k].time != ){
if(tr[k].len > )
Time(lc, tr[k].time),
Time(rc, tr[k].time);
tr[k].time = ;
}
if(tr[k].add){
if(tr[k].len > )
Add(lc, tr[k].add),
Add(rc, tr[k].add);
tr[k].add = ;
}
}
inline void modify(int k, int l, int r, int x, int y, int type, int v){
pushDown(k);
if(x <= l && r <= y){
switch(type){
case : Add(k, v); break;
case : Time(k, v); break;
case : Time(k, -), Add(k, v); break;
}
return;
}
int mid = l + r >> , lc = k << , rc = k << | ;
if(x <= mid) modify(lc, l, mid, x, y, type, v);
if(y > mid) modify(rc, mid + , r, x, y, type, v);
upt(k);
}
inline int query(int k, int l, int r, int x, int y){
pushDown(k);
if(x <= l && r <= y) return tr[k].sum;
int mid = l + r >> , lc = k << , rc = k << | , ret = ;
if(x <= mid) ret = (ret + query(lc, l, mid, x, y)) % Mod;
if(y > mid) ret = (ret + query(rc, mid + , r, x, y)) % Mod;
return ret;
}
}using namespace SegTree; inline int read(){
int i = , f = ; char ch = getchar();
for(; (ch < '' || ch > '') && ch != '-'; ch = getchar());
if(ch == '-') f = -, ch = getchar();
for(; ch >= '' && ch <= ''; ch = getchar())
i = (i << ) + (i << ) + (ch - '');
return i * f;
} inline void wr(int x){
if(x < ) putchar('-'), x = -x;
if(x > ) wr(x / );
putchar(x % + '');
} int main(){
n = read(), m = read();
for(int i = ; i <= n; i++) data[i] = read();
build(, , n);
for(int i = ; i <= m; i++){
int opt = read() + , a = read(), b = read(), c;
if(opt == || opt == || opt == )
c = read(), modify(, , n, a, b, opt, c);
else wr(query(, , n, a, b)), putchar('\n');
}
return ;
}
【序列操作III】线段树的更多相关文章
- BZOJ_1858_[Scoi2010]序列操作_线段树
BZOJ_1858_[Scoi2010]序列操作_线段树 Description lxhgww最近收到了一个01序列,序列里面包含了n个数,这些数要么是0,要么是1,现在对于这个序列有五种变换操作和询 ...
- 【BZOJ1858】序列操作(线段树)
[BZOJ1858]序列操作(线段树) 题面 BZOJ 题解 这题思路很简单,细节很烦,很码 维护区间翻转和区间赋值标记 当打到区间赋值标记时直接覆盖掉翻转标记 下放标记的时候先放赋值标记再放翻转标记 ...
- 【BZOJ2962】序列操作(线段树)
[BZOJ2962]序列操作(线段树) 题面 BZOJ 题解 设\(s[i]\)表示区间内选择\(i\)个数的乘积的和 考虑如何向上合并? \(s[k]=\sum_{i=0}^klson.s[i]*r ...
- [SCOI2010]序列操作 BZOJ1858 线段树
题目描述 lxhgww最近收到了一个01序列,序列里面包含了n个数,这些数要么是0,要么是1,现在对于这个序列有五种变换操作和询问操作: 0 a b 把[a, b]区间内的所有数全变成0 1 a b ...
- BZOJ1858 [Scoi2010]序列操作(线段树)
题目链接 [Scoi2010]序列操作 考验代码能力的一道好题. 思想还是很简单的(直接上线段树),但是比较难写. #include <bits/stdc++.h> using names ...
- [bzoj2962]序列操作_线段树_区间卷积
序列操作 bzoj-2962 题目大意:给定一个n个数的正整数序列,m次操作.支持:1.区间加:2.区间取相反数:3.区间求选c个数的乘积和. 注释:$1\le n,m\le 5\cdot 10^4$ ...
- 2019.01.04 bzoj2962: 序列操作(线段树+组合数学)
传送门 线段树基础题. 题意:要求维护区间区间中选择ccc个数相乘的所有方案的和(c≤20c\le20c≤20),支持区间加,区间取负. 由于c≤20c\le20c≤20,因此可以对于每个线段树节点可 ...
- bzoj1858SCOI 序列操作 (线段树)
题目大意: 给定一个长度为n的01序列为,现在有m种操作 \(0\ a\ b\) 把\([a,b]\)的数全部修改为0 \(1\ a\ b\) 把\([a,b]\)的数全部修改为1 \(2\ a\ b ...
- 序列操作 BZOJ2962 线段树
分析: 数据范围表示:c特别的小(c<20) 我们可以考虑nlogn*c^2的算法. 线段树维护区间信息:f[i]表示在[l,r]这段区间中选择i个数相乘的和. 因此,我们可以将区间看成一个点, ...
- BZOJ_2962_序列操作_线段树
Description 有一个长度为n的序列,有三个操作1.I a b c表示将[a,b]这一段区间的元素集体增加c,2.R a b表示将[a,b]区间内所有元素变成相反数,3.Q a b c表示询问 ...
随机推荐
- CView::OnPreparePrinting
http://technet.microsoft.com/zh-cn/subscriptions/a59dff1e(v=vs.71).aspx CView::OnPreparePrinting Cal ...
- Java对ad操作
转载:http://blog.csdn.net/binyao02123202/article/details/18697953
- spring接收对象数组实例
JS var param= new Array(); var one= new Object; one.id = '1'; one.name= 'simba1'; param.push(one); v ...
- Qt5 UI信号、槽自动连接的控件重名大坑(UI生成的槽函数存在一个隐患,即控件重名。对很复杂的控件,不要在 designer 里做提升,而是等到程序启动后,再动态创建,可以避免很多问题)
对Qt5稍有熟悉的童鞋都知道信号.槽的自动连接机制.该机制使得qt designer 设计的UI中包含的控件,可以不通过显式connect,直接和cpp中的相应槽相关联.该机制的详细文章见 http: ...
- 关于C语言的书
我想横着走,,哈哈哈哈
- 【习题5-5 UVA-10391】Compound Words
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举每一个串的分割点. 看看左右两个串在不在字符串中即可. [代码] #include <bits/stdc++.h> ...
- CD Linux U盘启动办法
1.用ULtraISO打开cdlinux的ISO文件,用USB-HDD+写入到U盘上。 2.下载GRUB4DOS软件,复制grldr和menu.lst到U盘。 3.下载bootice软件,在U盘的分区 ...
- C++利用SOAP开发WebService
// soapconsole.cpp : Defines the entry point for the console application.// #include "stdafx.h& ...
- 【LeetCode-面试算法经典-Java实现】【096-Unique Binary Search Trees(唯一二叉搜索树)】
[096-Unique Binary Search Trees(唯一二叉搜索树)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given n, how many s ...
- js中json数据简单处理(JSON.parse()和js中嵌套html)
js中json数据简单处理(JSON.parse()和js中嵌套html) 一.总结 1.html中嵌套js:<script>js代码</script> 2.js中嵌套html ...