记录编号 |
601922 |
评测结果 |
WWWTTTTTTT |
题目名称 |
2083.[SCOI2010]序列操作 |
最终得分 |
0 |
用户昵称 |
李奇文 |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
12.625 s |
提交时间 |
2025-06-29 17:31:24 |
内存使用 |
4.14 MiB |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
/*
int n,q;
int m[N];
struct node{
int l,r,lm,rm,len,sum,sz,num;
}t[8*N];
void pushup(int p){
t[p].sum=t[p<<1].sum+t[p<<1|1].sum;
t[p].lm=max(t[p<<1].lm,t[p<<1].sum+t[p<<1|1].lm);
t[p].rm=max(t[p<<1|1].rm,t[p<<1|1].sum+t[p<<1].rm);
t[p].len=max(max(t[p<<1].len,t[p<<1|1].len),t[p<<1].rm+t[p<<1|1].lm);
t[p].sz=t[p<<1].sz+t[p<<1|1].sz;
t[p].num=t[p<<1].num+t[p<<1|1].num;
}
void build(int p,int l,int r){
t[p].l=l,t[p].r=r;
if(l==r){
t[p].len=t[p].lm=t[p].rm=t[p].sum=m[l];
t[p].sz=1;
t[p].num=m[l];
return;
}
int mid=(l+r)>>1;
build(p<<1,l,mid);
build(p<<1|1,mid+1,r);
pushup(p);
}
node ask(int p,int x,int y){
if(x<=t[p].l&&t[p].r<=y){
return t[p];
}
int mid=(t[p].l+t[p].r)>>1;
if(mid>=y){
return ask(p<<1,x,y);
}
if(x>mid){
return ask(p<<1|1,x,y);
}
node ans,a=ask(p<<1,x,mid),b=ask(p<<1|1,mid+1,y);
ans.sum=a.sum+b.sum;
ans.lm=max(a.lm,a.sum+b.lm),ans.rm=max(b.rm,b.sum+a.rm);
ans.len=max(max(a.len,b.len),a.rm+b.lm);
return ans;
}
void ch(int p,int x,int y){
if(x<=t[p].l&&t[p].r<=y){
t[p].num=t[p].sz-t[p].num;
return;
}
}
int main(){
scanf("%d%d",&n,&q);
for(int i=1;i<=n;i++){
scanf("%d",&m[i]);
}
build(1,1,n);
while(q--){
int op,x,y;
scanf("%d%d%d",&op,&x,&y);
if(x>y){
swap(x,y);
}
if(op==0){
change(1,x,y,0);
}else if(op==1){
change(1,x,y,1);
}else if(op==2){
ch(1,x,y);
}else if(op==3){
printf("%d\n",query(1,x,y));
}else{
printf("%d\n",ask(1,x,y).len);
}
}
return 0;
}*/
int n,m,a[N];
int main(){
freopen("sequence.in","r",stdin);
freopen("sequence.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
while(m--){
int op,x,y;
scanf("%d%d%d",&op,&x,&y);
if(x>y){
swap(x,y);
}
if(op==0){
for(int i=x;i<=y;i++){
a[i]=0;
}
}else if(op==1){
for(int i=x;i<=y;i++){
a[i]=1;
}
}else if(op==2){
for(int i=x;i<=y;i++){
if(a[i]==1) a[i]=0;
else a[i]=1;
}
}else if(op==3){
int ans=0;
for(int i=x;i<=y;i++){
ans+=a[i];
}
printf("%d\n",ans);
}else{
int ans=0,sum=0;
for(int i=x;i<=y;i++){
if(a[i]==1){
sum++;
}else{
ans=max(sum,ans);
sum=0;
}
}
printf("%d\n",ans);
}
}
return 0;
}