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 OIer_FY @ 2023-10-26 22:10:11
输出超限?
by AlexandreLea @ 2023-10-26 22:10:20
@Tiramisu12 你调试代码没有删
by Double_Sheep @ 2023-10-26 22:26:43
@Jasminoides 我删全了啊??
by Double_Sheep @ 2023-10-26 22:27:12
@OIer_FY 不理解,但我调试的都删干净了啊
by Double_Sheep @ 2023-10-26 22:29:09
@Jasminoides print函数
就搁那了,用到print函数
的我都注释了
by a1co0av5ce5az1cz0ap_ @ 2023-10-26 22:33:14
@Tiramisu12 重新交一发
by Double_Sheep @ 2023-10-26 22:36:56
@ACaCaca_
emm 交了2发还这样 -。-
by a1co0av5ce5az1cz0ap_ @ 2023-10-27 07:11:41
@Tiramisu12 那段时间应该是洛谷爆了
by Sprague_Garundy @ 2023-10-27 16:23:12
@OIer_FY @Jasminoides @ACaCaca_ 不懂可以不回复吧。。
@Tiramisu12 结构体数组请使用构造函数而非 =
初始化,前者在运行期进行初始化,后者在编译期进行初始化(所以编译时间会很长),且后者会导致编译器输出的可执行文件过大(所以返回了 output exceeds
的错误),并编译超时被洛谷杀进程。
by a1co0av5ce5az1cz0ap_ @ 2023-10-27 16:32:50
@Sprague_Garundy 不是我都只看见了编译失败这情况一般不就是洛谷爆了?