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

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

记得倒着差分操作 因为题目保证操作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. Linux - 信息收集

    1. #!,代表加载器(解释器)的路径,如: #!/bin/bash echo "Hello Boy!" 上面的意思是说,把下面的字符(#!/bin/bash以下的所有字符)统统传 ...

  2. js面向对象过程

    var a = new  b(); 等价于 var a={}; a=b.prototype; b.call(a);

  3. mysql8.0.14 安装

    1.下载 地址:https://dev.mysql.com/downloads/mysql/ 找到zip压缩文件. 2.配置环境变量 把解压后的路径配置到环境变量中 3.安装 在解压后的文件夹中新建m ...

  4. Mysql字符串截取:Left()、Right()、Substring()、Substring_index()

    在实际的项目开发中有时会有对数据库某字段截取部分的需求,这种场景有时直接通过数据库操作来实现比通过代码实现要更方便快捷些, mysql有很多字符串函数可以用来处理这些需求,如Mysql字符串截取总结: ...

  5. 目标检测之Faster-RCNN的pytorch代码详解(模型准备篇)

    十月一的假期转眼就结束了,这个假期带女朋友到处玩了玩,虽然经济仿佛要陷入危机,不过没关系,要是吃不上饭就看书,吃精神粮食也不错,哈哈!开个玩笑,是要收收心好好干活了,继续写Faster-RCNN的代码 ...

  6. GBDT && XGBOOST

                                  GBDT && XGBOOST Outline Introduction GBDT Model XGBOOST Model ...

  7. PAT 1030 完美数列

    https://pintia.cn/problem-sets/994805260223102976/problems/994805291311284224 给定一个正整数数列,和正整数 p,设这个数列 ...

  8. PHP+AJAX 实现表格实时编辑

    https://blog.csdn.net/qq_29627497/article/details/81365107 源码链接:https://pan.baidu.com/s/1fAinVXU-nWt ...

  9. 在vue-cli创建的项目里配置scss

    第一步,gitbash进入到项目目录 npm install node-sass --save-dev npm install sass-loader --save-dev 第二步:打开webpack ...

  10. 玩adb和fastboot

    http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece7631046893b4c4380143fd3d1027fa3c215cc790a1b18 ...