————————————————————————————

这道题维护一下原序列的差分以及操作的差分就可以了

记得倒着差分操作 因为题目保证操作2的l r 小与当前位置

#include<cstdio>
#include<cstring>
#include<algorithm>
#define lowbit(x) x&-x;
using namespace std;
const int M=1e5+,mod=1e9+;
int read(){
int ans=,f=,c=getchar();
while(c<''||c>''){if(c=='-') f=-; c=getchar();}
while(c>=''&&c<=''){ans=ans*+(c-''); c=getchar();}
return ans*f;
}
int T,n,m;
int s[M],f[M];
struct pos{int k,l,r;}q[M];
void clear(){
memset(s,,sizeof(s));
memset(f,,sizeof(f));
}
int main(){
T=read();
while(T--){
n=read(); m=read(); clear();
for(int i=;i<=m;i++) q[i].k=read(),q[i].l=read(),q[i].r=read();
f[m]=;
for(int i=m;i;i--){
int k=q[i].k,l=q[i].l,r=q[i].r;
if(k==){
s[l]=(s[l]+f[i])%mod;
s[r+]=(s[r+]-f[i])%mod;
}
else{
f[l-]=(f[l-]-f[i])%mod;
f[r]=(f[r]+f[i])%mod;
}
f[i-]=(f[i-]+f[i])%mod;
}
int sum=;
for(int i=;i<=n;i++) sum=(sum+s[i])%mod,printf("%d ",(sum+mod)%mod); puts("");
}
return ;
}

codechef September Challenge 2017 Sereja and Commands的更多相关文章

  1. codechef September Challenge 2017 Fill The Matrix

    这道题我们发现0就代表相同1代表少1或者大1 那么我们根据题目连边 如果存在1(边权只为或0)个数为奇数的环就是无解 #include<cstdio> #include<cstrin ...

  2. Codechef September Challenge 2018 游记

    Codechef September Challenge 2018 游记 Magician versus Chef 题目大意: 有一排\(n(n\le10^5)\)个格子,一开始硬币在第\(x\)个格 ...

  3. September Challenge 2017

    Little Chef and Sums 分析:水题,去维护一下前缀和以及后缀和就好,注意long long #include "iostream" #include " ...

  4. codechef January Challenge 2017 简要题解

    https://www.codechef.com/JAN17 Cats and Dogs 签到题 #include<cstdio> int min(int a,int b){return ...

  5. codechef January Challenge 2014 Sereja and Graph

    题目链接:http://www.codechef.com/JAN14/problems/SEAGRP [题意] 给n个点,m条边的无向图,判断是否有一种删边方案使得每个点的度恰好为1. [分析] 从结 ...

  6. CF&&CC百套计划2 CodeChef December Challenge 2017 Chef And Easy Xor Queries

    https://www.codechef.com/DEC17/problems/CHEFEXQ 题意: 位置i的数改为k 询问区间[1,i]内有多少个前缀的异或和为k 分块 sum[i][j] 表示第 ...

  7. CF&&CC百套计划2 CodeChef December Challenge 2017 Chef and Hamming Distance of arrays

    https://www.codechef.com/DEC17/problems/CHEFHAM #include<cstdio> #include<cstring> #incl ...

  8. CF&&CC百套计划2 CodeChef December Challenge 2017 Total Diamonds

    https://www.codechef.com/DEC17/problems/VK18 #include<cstdio> #include<iostream> #includ ...

  9. CF&&CC百套计划2 CodeChef December Challenge 2017 Penalty Shoot-out

    https://www.codechef.com/DEC17/problems/CPLAY #include<cstdio> #include<algorithm> using ...

随机推荐

  1. 创建vpc网络

    vpc相关功能点: 模块 功能点 描述 备注 VPC 创建vpc网络 创建vpc网络,指定vpc网络名称   修改vpc网络 修改vpc网络名称   删除vpc网络 删除vpc网络   vpc相关命令 ...

  2. PyTorch深度学习计算机视觉框架

    Taylor Guo @ Shanghai - 2018.10.22 - 星期一 PyTorch 资源链接 图像分类 VGG ResNet DenseNet MobileNetV2 ResNeXt S ...

  3. HDU 4782 Beautiful Soup (模拟+注意细节)

    思路就是用栈模拟,不用开实体的栈,直接记一个top指针就行. 说说这题的细节: 1.tag标签里的内容不要动,原样输出.比如<p aa bb cc>,就这样输出就行,不要删空格.题目中说了 ...

  4. POJ 2761 Feed the dogs(平衡树or划分树or主席树)

    Description Wind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to feed the dogs ...

  5. POJ 2162 Document Indexing(模拟)

    Description Andy is fond of old computers. He loves everything about them and he uses emulators of o ...

  6. 并查集——hdu1213(入门)

    传送门:How Many Tables 模板代入 判断几个连通分支 DFS亦可完成 [并查集] #include <iostream> #include <cstdio> #i ...

  7. 父窗体和子窗体的显示,show&showdialog方法

    showdialog(): 子窗体弹出后,不能对父窗体进行操作.show()可以. 具体原理: 1.在调用Form.Show方法后,Show方法后面的代码会立即执行  2.在调用Form.ShowDi ...

  8. 页面加载时给的子元素的第一个元素加class

    HTML代码: <div id="xiao"> <ul> <li></li> </ul> </div> js ...

  9. Documentation & Markdown

    Documentation & Markdown markdown to document & document website generator https://github.co ...

  10. Java的sql语句 写关键字不需要添加单引号

    Java的sql语句 写关键字不需要添加单引号