Double_Sheep @ 2023-10-26 22:07:03
编译显示:
Nothing is compiled: OUTPUT exceeds.
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n,q,a[N];
struct node{
int v = -1e9,d = 0,op = 0;
}t[N * 4];
void print(int x,int l,int r){
printf("%d : %d %d %d %d\n",x,l,r,t[x].v,t[x].d);
if(l == r) return;
int mid = (l + r) >> 1;
print(x << 1,l,mid);
print(x << 1 | 1,mid + 1,r);
}
void build(int x,int l,int r){
if(l == r){
t[x].v = a[l];
return;
}
int mid = (l + r) >> 1;
build(x << 1,l,mid);
build(x << 1 | 1,mid + 1,r);
t[x].v = max(t[x << 1].v,t[x << 1 | 1].v);
}
void pushdown(int x,int l,int r){
if(!t[x].op) return;
t[x << 1].d = t[x].d,t[x << 1].op = t[x].op;
t[x << 1 | 1].d = t[x].d,t[x << 1 | 1].op = t[x].op;
if(t[x].op == 1){
t[x << 1].v = t[x].v;
t[x << 1 | 1].v = t[x].v;
}
else{
t[x << 1].v += t[x].v;
t[x << 1 | 1].v += t[x].v;
}
t[x].d = 0,t[x].op = 0;
}
void modify(int x,int l,int r,int ql,int qr,int v,int op){
if(ql == l && r == qr){
if(op == 1) t[x].v = v;
else t[x].v += v;
t[x].d = v,t[x].op = op;
return;
}
pushdown(x,l,r);
int mid = (l + r) >> 1;
if(ql <= mid) modify(x << 1,l,mid,ql,min(mid,qr),v,op);
if(qr > mid) modify(x << 1 | 1,mid + 1,r,max(mid + 1,ql),qr,v,op);
t[x].v = max(t[x << 1].v,t[x << 1 | 1].v);
}
int query(int x,int l,int r,int ql,int qr){
if(ql == l && qr == r)
return t[x].v;
pushdown(x,l,r);
int mid = (l + r) >> 1,ans = -1e9;
if(ql <= mid) ans = max(ans,query(x << 1,l,mid,ql,min(mid,qr)));
if(qr > mid) ans = max(ans,query(x << 1 | 1,mid + 1,r,max(mid + 1,ql),qr));
return ans;
}
int main(){
scanf("%d%d",&n,&q);
for(int i = 1;i <= n;i++)
scanf("%d",&a[i]);
build(1,1,n);
while(q--){
int op,l,r,v;
scanf("%d%d%d",&op,&l,&r);
if(op <= 2){
scanf("%d",&v);
modify(1,1,n,l,r,v,op);
}
else printf("%d\n",query(1,1,n,l,r));
//print(1,1,n); printf("\n");
}
return 0;
}
by Sprague_Garundy @ 2023-10-27 16:36:05
@ACaCaca_ 有没有一种可能洛谷老早就更新了自己不能看别人的编译失败信息。
by a1co0av5ce5az1cz0ap_ @ 2023-10-27 16:36:51
@Sprague_Garundy 好好好我一直不知道。
by Sprague_Garundy @ 2023-10-27 16:37:08
大概是两个月前更新的,你不知道也正常,毕竟小更新洛谷不会写更新日志里。据说是为了防止有人通过别人在比赛中提交的 CE 代码报错内容推测别人代码。
by AlexandreLea @ 2023-10-27 16:54:22
@Sprague_Garundy 谢谢提醒
by Double_Sheep @ 2023-10-27 20:13:47
@Sprague_Garundy 谢谢大佬