首先这题现在在BZOJ上是没数据的,你可以选择python2B获得AC,也可以去洛谷上交。
选择第一个选项的现在可以不用看了......

关于这题的题意,击破的一次攻击即使溢出也不双倍,否则你过不了样例。
然后考虑每个防御只会被击破一次,那么我们可以像HEOI2017相逢是问候那样用一个线段树去维护是否被击破。
然而那个题每次暴力push到底就行了,但这个题如果这样做,会发现在push时可能没有任何防御被击破,复杂度不对......
考虑用奇怪的办法保证存在防御被击破,我们维护区间的min,如果这个区间的min<=当前攻击值,则我们有必要在这个区间push到底。
然后就是实现的问题,自己YY一下就好了,我是用一个单独的函数去实现的push到底这个操作......
注意各种分类讨论......
别问我为什么刷这种水题......
今天好不容易不考试写神题也写不动啊......

我的代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define debug cout
typedef long long int lli;
using namespace std;
const int maxn=1e5+1e2;
const int mod=1e9+;
const int inf=0x3f3f3f3f; int in[maxn<<];
int l[maxn<<],r[maxn<<],lson[maxn<<],rson[maxn<<],siz[maxn<<],full[maxn<<],cnt; // size means number needs to be doubled .
lli sum[maxn<<],miv[maxn<<],lazy[maxn<<]; // lazy means attack not pushsed ( not doubled ) . inline void build(int pos,int ll,int rr) {
l[pos] = ll , r[pos] = rr , full[pos] = rr - ll + ;
if( ll == rr ) {
miv[pos] = in[ll];
return;
} const int mid = ( ll + rr ) >> ;
build(lson[pos]=++cnt,ll,mid) , build(rson[pos]=++cnt,mid+,rr);
miv[pos] = min( miv[lson[pos]] , miv[rson[pos]] );
}
inline void apply(int pos,lli x) {
lazy[pos] += x , sum[pos] += ( full[pos] + siz[pos] ) * x;
if( miv[pos] != inf ) miv[pos] -= x;
}
inline void push(int pos) {
if( !lazy[pos] ) return;
apply(lson[pos],lazy[pos]) , apply(rson[pos],lazy[pos]) , lazy[pos] = ;
}
inline void maintain(int pos) {
siz[pos] = siz[lson[pos]] + siz[rson[pos]] ,
sum[pos] = sum[lson[pos]] + sum[rson[pos]] ,
miv[pos] = min( miv[lson[pos]] , miv[rson[pos]] );
}
inline void chain(int pos,lli x) {
if( x < miv[pos] ) { // nothing will be destoryed .
apply(pos,x);
return;
}
if( l[pos] == r[pos] ) { // assert x <= miv[pos] .
sum[pos] += x , siz[pos] = , miv[pos] = inf;
} else { // push lazy at the same time .
chain(lson[pos],x+lazy[pos]) , chain(rson[pos],x+lazy[pos]) , lazy[pos] = ;
maintain(pos);
}
}
inline void update(int pos,int ll,int rr,lli x) {
if( r[pos] < ll || rr < l[pos] ) return;
if( ll <= l[pos] && r[pos] <= rr ) return chain(pos,x);
push(pos);
update(lson[pos],ll,rr,x) , update(rson[pos],ll,rr,x);
maintain(pos);
}
inline lli query(int pos,int ll,int rr) {
if( r[pos] < ll || rr < l[pos] ) return ;
if( ll <= l[pos] && r[pos] <= rr ) return sum[pos];
push(pos);
return query(lson[pos],ll,rr) + query(rson[pos],ll,rr);
} int main() {
static int n,m;
static char o[];
static lli ans;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++) scanf("%d",in+i);
build(cnt=,,n);
for(int i=,l,r,x;i<=m;i++) {
scanf("%s%d",o,&l);
if( *o == 'A' ) {
scanf("%d%d",&r,&x);
update(,l,r,x);
} else if( *o == 'Q' ) {
( ans += query(,l,l) % mod ) %= mod;
}
}
printf("%lld\n",ans);
return ;
}

最后给大家送上数据和对拍器,用lemon的格式打包的。

链接: https://pan.baidu.com/s/1n518YAQFYH02hi2ZNB41EQ 密码: ahym

Bzoj5209[Tjoi2012]防御:姿势题的更多相关文章

  1. [TJOI2012]防御

    https://www.zybuluo.com/ysner/note/1332539 题面 戳我 解析 一道挺棒棒的线段树. 显然一次伤害到来时我们要先看看区间内哪些点的护甲没了. 这个可以通过维护区 ...

  2. 浅谈XXE漏洞攻击与防御——本质上就是注入,盗取数据用

    浅谈XXE漏洞攻击与防御 from:https://thief.one/2017/06/20/1/ XML基础 在介绍xxe漏洞前,先学习温顾一下XML的基础知识.XML被设计为传输和存储数据,其焦点 ...

  3. ref:浅谈XXE漏洞攻击与防御

    ref:https://thief.one/2017/06/20/1/ 浅谈XXE漏洞攻击与防御 发表于 2017-06-20   |   分类于 web安全  |   热度 3189 ℃ 你会挽着我 ...

  4. 1.浅谈XXE漏洞攻击与防御

    XML基础 在介绍XXE漏洞前,先学习温顾一下XML的基础知识.XML被设计为传输和存储数据,其焦点是数据的内容,其把数据从HTML分离,是独立于软件和硬件的信息传输工具. XML是一种用于标记电子文 ...

  5. 【入门推荐】SQL注入进行WebShell渗透测试的基础概览

    作者:zero 本文为SQL基本注入的进阶文章,如有任何疑问请查看: SQL基本注入演示:https://www.cnblogs.com/anbus/p/10082452.html 导语: 利用SQL ...

  6. 2015ACM/ICPC Asia Regional Changchun Online /HDU 5438 图

    Ponds                                   Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 1310 ...

  7. MySQL 拿 WebShell

    两种常规方法利用 MySQL getshell 的方法: select … into outfile general_log 一.select … into outfile 介绍 利用需要满足以下条件 ...

  8. MySQL获取webshell的几种方式

    select ... into outfile 需要满足的条件 对web目录有写权限 GPC关闭(GPC:是否对单引号转义) 有绝对路径(读文件可以不用,写文件需要) 没有配置secure-file- ...

  9. Bypass 护卫神SQL注入防御(多姿势)

    0x00 前言 ​ 护卫神一直专注服务器安全领域, 其中有一款产品,护卫神·入侵防护系统 ,提供了一些网站安全防护的功能,在IIS加固模块中有一个SQL防注入功能. 这边主要分享一下几种思路,Bypa ...

随机推荐

  1. Django中Celery http请求异步处理(四)

    Django中Celery http请求异步处理 本章延续celery之前的系列 1.settings配置 2.编写task jib_update_task任务为更新salt jid数据 3.url设 ...

  2. 浮动和margin-left负值的有趣现象

    我将第二个浮动的元素的margin-left的值不断减小: 被设置元素左移,后面的元素跟着动 当被设置元素的右边界超过了前面元素的左边界,后面边的元素被前面的元素挡在外面了

  3. Firefox滚动残影(转)

    Firefox滚动残影   Firefox滚动残影这文章放在草稿箱有一阵子了,之前的3系列都有这BUG,当正想发表这文章的时候,和我沟通刚刚升级的FF4已修复此BUG,所以搁置一阵在考虑到这文章还有没 ...

  4. WIN10文件无法自动刷新问题解决方法

    Window10系统有时候会遇到以下类似的问题 1.文件删除后,图标还在,无法自动刷新屏幕,按F5或右键菜单刷新后才消失 2.文件粘贴后,不显示,刷新后才显示 3.回收站清理后,文件图标仍显示有垃圾 ...

  5. Kali社会工程学攻击--powershell 攻击(无视防火墙)

    1.打开setoolkit 输入我们反弹shell的地址与端口 2.修改我的shellcode 3.攻击成功

  6. Linux sleep命令

    Linux sleep命令可以用来将目前动作延迟一段时间. 使用权限:所有使用者. 语法 sleep [--help] [--version] number[smhd] 参数说明: --help : ...

  7. 洛谷 P3749: LOJ 2146: [SHOI2017]寿司餐厅

    题目传送门:LOJ #2146. 题意简述: 有 \(n\) 种寿司,第 \(i\) 种寿司的类型为 \(a_i\). 如果你吃了第 \(i\) 种到第 \(j\) 种寿司,你会得到 \(d_{i,j ...

  8. MySQL 5.6.10 跨平台GTID复制实践

    根据业务需要,建立MySQL复制来实现数据冗余. 1:binlog_format   默认值是:statement 有效值: ROW,基于行的复制 STATEMENT 基于语句级别的复制 MASTER ...

  9. [cookie篇]cookie-parser之parser.js

    cookie-parser的作用,官方的说法是:Parse Cookie header and populate req.cookies with an object keyed by the coo ...

  10. 不能访问本地服务器场。没有注册带有FeatureDependencyId 的 Cmdlet

      不能访问本地服务器场.没有注册带有FeatureDependencyId 的 Cmdlet. 原因: 我有两个域管理员账号,分别:sp\administrator,sp\spadmin 其中后者才 ...