题意:

n,q<=1e5,a[i],b[i][j]<=1e9,保证能力值互不相同,询问之间保留前面的影响

思路:其实把大于a[1]的看成0,小于的看成1,设第i天小于a[1]的有b[i]个,本质上就是这样一个过程:

刚开始有b[0]个小于a[1]的,第1天先减去r[1]看是否小于0,若小于0则结束,再加上b[1],以此类推

由此可见每次询问只是单点修改了b[x],判断的话就是在判最小的前缀和是否<0

用线段树维护一下最小的前缀和即可

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> PII;
typedef pair<ll,ll> Pll;
typedef vector<int> VI;
typedef vector<PII> VII;
//typedef pair<ll,ll>P;
#define N 200010
//#define M 200010
#define INF 1e9
#define fi first
#define se second
#define MP make_pair
#define pb push_back
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define per(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define lowbit(x) x&(-x)
#define Rand (rand()*(1<<16)+rand())
#define id(x) ((x)<=B?(x):m-n/(x)+1)
#define ls p<<1
#define rs p<<1|1 const ll MOD=1e9+,inv2=(MOD+)/;
double eps=1e-;
int dx[]={-,,,};
int dy[]={,,-,}; struct node
{
int s,tag;
}t[N<<]; vector<int> c[N];
int r[N],b[N],a[N],d[N]; int read()
{
int v=,f=;
char c=getchar();
while(c<||<c) {if(c=='-') f=-; c=getchar();}
while(<=c&&c<=) v=(v<<)+v+v+c-,c=getchar();
return v*f;
} void pushdown(int p)
{
if(t[p].tag!=)
{
t[ls].s+=t[p].tag;
t[rs].s+=t[p].tag;
t[ls].tag+=t[p].tag;
t[rs].tag+=t[p].tag;
t[p].tag=;
}
} void pushup(int p)
{
t[p].s=min(t[ls].s,t[rs].s);
} void build(int l,int r,int p)
{
if(l==r)
{
t[p].s=d[l];
t[p].tag=;
return;
}
int mid=(l+r)>>;
build(l,mid,ls);
build(mid+,r,rs);
pushup(p);
} void update(int l,int r,int x,int y,int v,int p)
{
if(x<=l&&r<=y)
{
t[p].s+=v;
t[p].tag+=v;
return;
}
pushdown(p);
int mid=(l+r)>>;
if(x<=mid) update(l,mid,x,y,v,ls);
if(y>mid) update(mid+,r,x,y,v,rs);
pushup(p);
} int main()
{
//freopen("1.in","r",stdin);
int n=read(),m=read(),q=read();
rep(i,,n) a[i]=read();
rep(i,,n)
if(a[i]<a[]) b[]++;
r[]=;
rep(i,,m)
{
r[i]=read();
b[i]=;
c[i].pb(-);
rep(j,,r[i])
{
int x=read();
c[i].pb(x);
if(x<a[]) b[i]++;
}
}
rep(i,,n) d[i]=d[i-]+b[i-]-r[i-];
rep(i,,n) d[i]-=r[i]; build(,m,);
while(q--)
{
int x=read(),y=read(),z=read();
if(c[x][y]<a[]&&z>a[])
{
b[x]--;
if(x+<=m) update(,m,x+,m,-,);
}
if(c[x][y]>a[]&&z<a[])
{
b[x]++;
if(x+<=m) update(,m,x+,m,,);
}
int tmp=t[].s;
if(tmp<) printf("0\n");
else printf("1\n");
c[x][y]=z;
}
return ;
}

【CF1252G】Performance Review(线段树)的更多相关文章

  1. HDU5023:A Corrupt Mayor's Performance Art(线段树区域更新+二进制)

    http://acm.hdu.edu.cn/showproblem.php?pid=5023 Problem Description Corrupt governors always find way ...

  2. hdu 5023 A Corrupt Mayor's Performance Art 线段树

    A Corrupt Mayor's Performance Art Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 100000/100 ...

  3. hdu----(5023)A Corrupt Mayor's Performance Art(线段树区间更新以及区间查询)

    A Corrupt Mayor's Performance Art Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 100000/100 ...

  4. HDU 5023 A Corrupt Mayor's Performance Art 线段树区间更新+状态压缩

    Link:  http://acm.hdu.edu.cn/showproblem.php?pid=5023 #include <cstdio> #include <cstring&g ...

  5. A Corrupt Mayor's Performance Art(线段树区间更新+位运算,颜色段种类)

    A Corrupt Mayor's Performance Art Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 100000/100 ...

  6. ACM学习历程—HDU 5023 A Corrupt Mayor's Performance Art(广州赛区网赛)(线段树)

    Problem Description Corrupt governors always find ways to get dirty money. Paint something, then sel ...

  7. HDU 5023 A Corrupt Mayor's Performance Art(线段树区间更新)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5023 解题报告:一面墙长度为n,有N个单元,每个单元编号从1到n,墙的初始的颜色是2,一共有30种颜色 ...

  8. HDU 5023 A Corrupt Mayor's Performance Art (据说是线段树)

    题意:给定一个1-n的墙,然后有两种操作,一种是P l ,r, a 把l-r的墙都染成a这种颜色,另一种是 Q l, r 表示,输出 l-r 区间内的颜色. 析:应该是一个线段树+状态压缩,但是我用s ...

  9. hdu - 5023 - A Corrupt Mayor's Performance Art(线段树)

    题目原文废话太多太多太多,我就不copyandpaste到这里啦..发个链接吧题目 题目意思就是:P  l  r  c  将区间 [l ,r]上的颜色变成c    Q  l r 就是打印出区间[l,r ...

随机推荐

  1. Chapter03 第二节 const限定符的使用

    3.2 const限定符 const的作用:替代#define作为有类型检查的常量来使用.他的值被初始化后就固定了,成为一个只读变量,不能更改.(推荐使用特殊的命名规范来区分常量和非常量). cons ...

  2. finereport点击图表钻取到明细表包括参数传递

    1.  点击编辑图表 2.  参数传递 3.  选择分类名称 4.  钻取明细表获取 inputs 值得方法 使用公司 $inputs   获取钻取传来的值

  3. 更新代码 出现 You need to upgrade the working copy first 错误

    今天更新了Eclipse的subclipse插件,更新代码报如下错误: svn: The working copy at 'E:\591woospace\kst_fashion_alipay_v1.2 ...

  4. 前端 CSS 盒子模型 边框 border属性

    边框 border:边框的意思,描述盒子的边框 边框有三个要素: 粗细 线性样式 颜色 border: solid border特性 如果颜色不写,默认是黑色.如果粗细不写,不显示边框.如果只写线性样 ...

  5. Bubble Sort(冒泡排序)

    冒泡排序(英语:Bubble Sort,台湾另外一种译名为:泡沫排序)是一种简单的排序算法.它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.走访数列的工作是重复地进行 ...

  6. [转帖]是时候深入了解Linux的系统结构

    是时候深入了解Linux的系统结构   http://os.51cto.com/art/201905/596011.htm linux的体系结果 其实自己也知道 linus 做了一个 kernel 大 ...

  7. 2016青岛区域赛.Coding Contest(费用流 + 概率计算转换为加法计算)

    Coding Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  8. 安装配置php及fastadmin

    FastAdmin教程之准备运行环境   一.Node.js http://nodejs.cn/download/ https://npm.taobao.org/mirrors/node/v8.4.0 ...

  9. 小z的洞穴之旅 QDUOJ 并查集+连通块

    小z的洞穴之旅 QDUOJ 并查集+连通块 原题链接 题意 小 z 同学在某个闲暇的周末决定去野外探险一波,结果在丛林深处中误打误撞进入了一个神秘的洞穴,虽然洞穴中光线昏暗,但小 z 凭借其敏锐的眼力 ...

  10. PythonDay08

    第八章 今日内容 文件操作 读操作 写操作 +操作 其他操作 读操作 r模式f = open('test.txt', mode='r', encoding='utf-8')print(f.read() ...