题目链接:
题目分析:
很裸的分块题,最开始在原数组上排序WA掉了,还因此调了很久23333
代码:
#include#define MAXN (1000000+5)using namespace std;inline int read(){ int cnt=0,f=1;char c; c=getchar(); while(!isdigit(c)){ if(c=='-')f=-f; c=getchar(); } while(isdigit(c)){ cnt=cnt*10+c-'0'; c=getchar(); } return cnt*f;}int n,a[MAXN],q,L[MAXN],R[MAXN],add[MAXN],pos[MAXN],b[MAXN];char opr;int find(int l,int r,int c){ int ll=l;int rr=r; int mid=(ll+rr)>>1; int u=pos[mid]; if(b[rr]+add[u] >1; if(b[mid]+add[u]>=c)rr=mid; else ll=mid+1;// cout< <<" "< <<" "< < =C)ans++; } } return ans;}int A,B,C;int main(){// freopen("1.in","r",stdin); n=read();q=read(); for(register int i=1;i<=n;i++){ a[i]=read();b[i]=a[i]; } int t=sqrt(n); for(register int i=1;i<=t;i++){ L[i]=(i-1)*t+1; R[i]=i*t; } if(R[t] >opr;A=read();B=read();C=read(); if(opr=='M')change(A,B,C); if(opr=='A')printf("%d\n",query(A,B,C));// for(register int i=1;i<=n;i++)printf("%d ",a[i]);// printf("\n");// for(register int i=1;i<=t;i++)printf("%d ",add[i]);// printf("\n"); } return 0;}
调试语句巨多,凑合看……
话说最近的博客为什么都是两句话说完的风格了啊一定是被fsy带坏了