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 ...
随机推荐
- OBS源码编译开发
本文来自网易云社区 作者:梁敏 OBS简介 OBS(Open Broadcaster Software)是免费开源的视频录制和直播软件,支持运行在windows,Mac和linux平台.官方链接 ht ...
- c# 3D图形处理库
C#的OpenGL类库SharpGL SharpGL 可以让你在 Windows Forms 或者 WPF 应用中轻松的使用 OpenGL 开发图形应用.更多SharpGL信息 Axiom 3D En ...
- 给移动硬盘安装rhel7
本机是win8.1的系统,但不想给电脑装双系统,所以想给移动硬盘里安装rhel7移动硬盘是750G的在网上搜了很多方法,我采取了两个方法:方法一.1.取一个U盘,用软碟通把rhel7的iso文件写进了 ...
- 以太坊solidity编程常见错误(不定期更新)
1.报错: Expected token Semicolon got 'eth_compileSolidity' funtion setFunder(uint _u,uint _amount){ 解决 ...
- php+Mysql中网页出现乱码的解决办法详解
$conn = mysql_connect("$host","$user","$password");mysql_query("S ...
- 软件工程项目组Z.XML会议记录 2013/11/20
软件工程项目组Z.XML会议记录 [例会时间]2013年11月20日星期三21:00-22:00 [例会形式]小组讨论 [例会地点]学生公寓3号楼会客厅 [例会主持]李孟 [会议记录]李孟 会议整体流 ...
- 支持ie的时间控件 html
连接:http://www.my97.net/demo/resource/2.4.asp#m248 下载测试:链接: https://pan.baidu.com/s/17AdRa2OTLPI7ndiA ...
- 软工实践 - 第二十六次作业 Beta 冲刺(4/7)
队名:起床一起肝活队 组长博客:https://www.cnblogs.com/dawnduck/p/10124816.html 作业博客:班级博客本次作业的链接 组员情况 组员1(队长):白晨曦 过 ...
- 找jar包的网址
http://search.maven.org/#search%7Cga%7C1%7Cmybatis http://mvnrepository.com/
- BZOJ4423 AMPPZ2013Bytehattan(并查集)
判断网格图中某两点是否被割开,可以将割边视为边区域视为点,转化为可切割这两点的区域是否连通.于是每次判断使两个区域连通后是否会形成环(边界视为连通),若是则说明被两点被割开.并查集维护. #inclu ...