提交后会显示
编译信息 源代码
编译信息 编译失败
怀疑是File size limit exceeded
求助求助
代码:
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define MID int mid=(l+r)>>1
#define ll long long
using namespace std;
const int N = 1e5+1e2,inf=0x3f3f3f3f;
const ll llinf = 2e18;
struct rec{
int mx=-inf,mi=inf,max_l=-inf,min_r=inf;
bool ez=0;
};
rec operator + (rec a,rec b){
rec c;
c.mi=min(a.mi,b.mi),c.mx=max(a.mx,b.mx);
c.ez=a.ez||b.ez;
c.max_l=max(a.max_l,b.max_l),c.min_r=min(a.min_r,b.min_r);
return c;
}
class TREE{
rec t[N*4];
public:void build(int rt,int l,int r){
if(l==r){
int x;scanf("%d",&x);
t[rt].mi=t[rt].mx=x;
if(x>0) t[rt].min_r=x;
else if(x<0) t[rt].max_l=x;
else t[rt].ez=0;
return ;
}
MID;
build(ls,l,mid);
build(rs,mid+1,r);
t[rt]=t[ls]+t[rs];
}
rec query(int rt,int l,int r,int ql,int qr){
if(ql<=l && r<=qr){
return t[rt];
}
MID;
rec res;
if(mid>=ql) res=query(ls,l,mid,ql,qr);
if(mid<qr) res=res+query(rs,mid+1,r,ql,qr);;
return res;
}
}t1,t2;
int n,m,q;
ll fun(int x,rec y){
if(x>0) return 1ll*y.mi*x;
if(x<0) return 1ll*y.mx*x;
return 0;
}
void get(ll &a,ll b){
if(a>=llinf) a=b;
else a=max(a,b);
}
signed main(void)
{
scanf("%d%d%d",&n,&m,&q);
t1.build(1,1,n);
t2.build(1,1,m);
while(q--){
int l1,r1,l2,r2;
scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
rec x=t1.query(1,1,n,l1,r1);
rec y=t2.query(1,1,m,l2,r2);
ll ans=llinf;
if(x.mx>0){
get(ans,fun(x.mx,y));
get(ans,fun(x.min_r,y));
}
if(x.mi<0){
get(ans,fun(x.mi,y));
get(ans,fun(x.max_l,y));
}
if(x.ez) get(ans,0);
printf("%lld\n",ans);
}
return 0;
}