codechef September Challenge 2017 Sereja and Commands


————————————————————————————
这道题维护一下原序列的差分以及操作的差分就可以了
记得倒着差分操作 因为题目保证操作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的更多相关文章
- codechef September Challenge 2017 Fill The Matrix
这道题我们发现0就代表相同1代表少1或者大1 那么我们根据题目连边 如果存在1(边权只为或0)个数为奇数的环就是无解 #include<cstdio> #include<cstrin ...
- Codechef September Challenge 2018 游记
Codechef September Challenge 2018 游记 Magician versus Chef 题目大意: 有一排\(n(n\le10^5)\)个格子,一开始硬币在第\(x\)个格 ...
- September Challenge 2017
Little Chef and Sums 分析:水题,去维护一下前缀和以及后缀和就好,注意long long #include "iostream" #include " ...
- codechef January Challenge 2017 简要题解
https://www.codechef.com/JAN17 Cats and Dogs 签到题 #include<cstdio> int min(int a,int b){return ...
- codechef January Challenge 2014 Sereja and Graph
题目链接:http://www.codechef.com/JAN14/problems/SEAGRP [题意] 给n个点,m条边的无向图,判断是否有一种删边方案使得每个点的度恰好为1. [分析] 从结 ...
- 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] 表示第 ...
- 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 ...
- CF&&CC百套计划2 CodeChef December Challenge 2017 Total Diamonds
https://www.codechef.com/DEC17/problems/VK18 #include<cstdio> #include<iostream> #includ ...
- CF&&CC百套计划2 CodeChef December Challenge 2017 Penalty Shoot-out
https://www.codechef.com/DEC17/problems/CPLAY #include<cstdio> #include<algorithm> using ...
随机推荐
- 读取Excel错误,未在本地计算机上注册 oledb.4.0
以前写的一个读取Excel的程序,现在在另外一台机器上运行,竟然报错说"未在本地计算机上注册 oledb.4.0" 最后才知道,原来是因为现在运行的那台电脑 ...
- 现代web开发需要学习的15大技术
现代Web开发需要学习的15大技术 2016-06-08 13:08 快进到现在,我发现现代web开发再一次将发生压倒性的改变.信息资讯的铺天盖地令人迷惑,尤其对于初学者而言.首要原因是新的框架,例如 ...
- spring mvc 返回xml格式数据
1.问题 : 因为业务需要,需要发送xml格式的数据,使用spring mvc 自己解析,就不用费心去自己搞这些东西. 2.解决: 新建一个实体类,直接在实体类中添加注解即可,如下: @XmlRoot ...
- ASP NET Core ---POST, PUT, PATCH, DELETE,Model 验证
参照 草根专栏- ASP.NET Core + Ng6 实战:https://v.qq.com/x/page/u0765jbwc6f.html 一.POST 安全性和幂等性 安全性是指方法执行后并不会 ...
- 为Zabbix配置Nova服务、Keystone和Placement进程CPU和内存usage监控
目前已经完成了RabbitMQ和MySQL的监控项配置,还差对nova-api.nova-conductor.nova-scheduler和keystone进程CPU和内存 usage的监控,类似的轮 ...
- 学习人工智能的第五个月[字典学习[Dictionary Learning,DL]]
摘要: 大白话解释字典学习,分享第五个月的学习过程,人生感悟,最后是自问自答. 目录: 1.字典学习(Dictionary Learning,DL) 2.学习过程 3.自问自答 内容: 1.字典学习( ...
- Python 学习笔记之—— PIL 库
PIL,全称 Python Imaging Library,是 Python 平台一个功能非常强大而且简单易用的图像处理库.但是,由于 PIL 仅支持到Python 2.7,加上年久失修,于是一群志愿 ...
- picker组件,mode=date,苹果机年份从1开始
由于在IOS上复制图片不方便, 所以用了张别的网站的图 这是在没有设置value和start的情况下出现的,安卓机上显示是好的.尝试完网上相关说法, 发现都不中! 通过各种挣扎啊!~ 心里苦啊~ 复制 ...
- HDU 4587 TWO NODES(割点)(2013 ACM-ICPC南京赛区全国邀请赛)
Description Suppose that G is an undirected graph, and the value of stab is defined as follows: Amon ...
- [整理]docker内部时区修改的两种方法
方法一 终端执行 date命令,查看宿主服务器的时区是否正确 如果正确: 执行 docker cp /etc/localtime 容器ID:/etc/localtime 将本地时间拷贝到docker内 ...