我知道我的代码又臭又长,能不能请诸位大佬查一下RE的原因(指出来就行)
小样例是过了的,大样例不知道为什么out文件里输不出来
(如果看不出来原因告诉我几种程序RE的情况也行)
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf=0x3f3f3f3f;
const int maxn=1e5+1;
const int lgo=50;
int n,m,t;
int l1,r1,l2,r2;
int lg[lgo];
int f1=0,f2=0,o1=0,o2=0;
int z1=0,z2=0;
//维护 我方正数最大值 我方正数最小值 我方负数最大值 我方负数最小值 我方0
// az1 iz1 af1 if1 oo1
//维护 敌方正数最大值 敌方正数最小值 敌方负数最大值 敌方负数最小值 敌方0
// az2 iz2 af2 if2 oo2
int staz1[maxn][lgo],stiz1[maxn][lgo],staf1[maxn][lgo],stif1[maxn][lgo],oo1[maxn][lgo];
int staz2[maxn][lgo],stiz2[maxn][lgo],staf2[maxn][lgo],stif2[maxn][lgo],oo2[maxn][lgo];
int max_z(int a,int b){
if(a>0||b>0){
return max(a,b);
}
else{
return 0;
}
}
int max_f(int a,int b){
if(a<0&&b<0){
return max(a,b);
}
else if(a<0||b<0){
return min(a,b);
}
else {
return -inf;
}
}
int min_z(int a,int b){
if(a>0&&b>0){
return min(a,b);
}
else if(a>0||b>0){
return max(a,b);
}
else {
return inf;
}
}
int min_f(int a,int b){
if(a<0||b<0){
return min(a,b);
}
else {
return 0;
}
}
int oo(int a,int b){
if(a==0||b==0){
return 0;
}
else {
return 1;
}
}
signed main(){
//freopen("game.in","r",stdin);
//freopen("game.out","w",stdout);
int a[maxn],b[maxn];
cin>>n>>m>>t;
for(int i=2;i<=max(n,m);i++){
lg[i]=lg[i/2]+1;
}
for(int i=1;i<=n;i++){
cin>>a[i];
staz1[i][0]=a[i];
stiz1[i][0]=a[i];
staf1[i][0]=a[i];
stif1[i][0]=a[i];
oo1[i][0]=a[i];
}
for(int j=1;j<=lg[n];j++){
for(int i=1,tmp=(1<<j)-1;i+tmp<=n;i++){
staz1[i][j]=max_z(staz1[i][j-1],staz1[i+(1<<(j-1))][j-1]);
stiz1[i][j]=min_z(stiz1[i][j-1],stiz1[i+(1<<(j-1))][j-1]);
staf1[i][j]=max_f(staf1[i][j-1],staf1[i+(1<<(j-1))][j-1]);
stif1[i][j]=min_f(stif1[i][j-1],stif1[i+(1<<(j-1))][j-1]);
oo1[i][j]=oo(oo1[i][j-1],oo1[i+(1<<(j-1))][j-1]);
}
}
for(int i=1;i<=m;i++){
cin>>b[i];
staz2[i][0]=b[i];
stiz2[i][0]=b[i];
staf2[i][0]=b[i];
stif2[i][0]=b[i];
oo2[i][0]=b[i];
}
for(int j=1;j<=lg[m];j++){
for(int i=1,tmp=(1<<j)-1;i+tmp<=m;i++){
staz2[i][j]=max_z(staz2[i][j-1],staz2[i+(1<<(j-1))][j-1]);
stiz2[i][j]=min_z(stiz2[i][j-1],stiz2[i+(1<<(j-1))][j-1]);
staf2[i][j]=max_f(staf2[i][j-1],staf2[i+(1<<(j-1))][j-1]);
stif2[i][j]=min_f(stif2[i][j-1],stif2[i+(1<<(j-1))][j-1]);
oo2[i][j]=oo(oo2[i][j-1],oo2[i+(1<<(j-1))][j-1]);
}
}
while(t--){
f1=0,f2=0,o1=0,o2=0;
z1=0,z2=0;
int az1=-inf,iz1=inf,az2=-inf,iz2=inf;
int af1=-inf,if1=inf,af2=-inf,if2=inf;
int o1o=0,o2o=0;
cin>>l1>>r1>>l2>>r2;
int k1=lg[r1-l1+1];
az1=max_z(staz1[l1][k1],staz1[r1-(1<<k1)+1][k1]);
iz1=min_z(stiz1[l1][k1],stiz1[r1-(1<<k1)+1][k1]);
af1=max_f(staf1[l1][k1],staf1[r1-(1<<k1)+1][k1]);
if1=min_f(stif1[l1][k1],stif1[r1-(1<<k1)+1][k1]);
o1o=oo(oo1[l1][k1],oo1[r1-(1<<k1)+1][k1]);
if(az1>0){
z1=1;
}
if(iz1<inf){
z1=1;
}
if(af1>-inf){
f1=1;
}
if(if1<0){
f1=1;
}
if(o1o==0){
o1=1;
}
int k2=lg[r2-l2+1];
az2=max_z(staz2[l2][k2],staz2[r2-(1<<k2)+1][k2]);
iz2=min_z(stiz2[l2][k2],stiz2[r2-(1<<k2)+1][k2]);
af2=max_f(staf2[l2][k2],staf2[r2-(1<<k2)+1][k2]);
if2=min_f(stif2[l2][k2],stif2[r2-(1<<k2)+1][k2]);
o2o=oo(oo2[l2][k2],oo2[r2-(1<<k2)+1][k2]);
if(az2>0){
z2=1;
}
if(iz2<inf){
z2=1;
}
if(af2>-inf){
f2=1;
}
if(if2<0){
f2=1;
}
if(o2o==0){
o2=1;
}
//max(dp[l][k],dp[r-(1<<k)+1][k])
if(z1){
if(z2){
if(f1){
if(f2){
if(o1){
if(o2)cout<<0;
else cout<<0;
}else{
if(o2)cout<<iz1*if2;////////
else cout<<max(iz1*if2,af1*az2);
}
}
else{
if(o1){
if(o2)cout<<0;
else cout<<az1*iz2;//
}else{
if(o2)cout<<0;
else cout<<az1*iz2;
}
}
}else{
if(f2){
if(o1){
if(o2)cout<<0;
else cout<<0;
}else{
if(o2)cout<<iz1*if2;////////
else cout<<iz1*if2;////////
}
}
else{
if(o1){
if(o2)cout<<0;
else cout<<az1*iz2;
}else{
if(o2)cout<<0;
else cout<<az1*iz2;
}
}
}
}else{
if(f1){
if(f2){
if(o1){
if(o2)cout<<0;
else cout<<if1*af2;
}else{
if(o2)cout<<0;/////////
else cout<<if1*af2;//////////
}
}
else{
if(o1){
if(o2)cout<<0;
}else{
if(o2)cout<<0;
}
}
}else{
if(f2){
if(o1){
if(o2)cout<<0;
else cout<<0;
}else{
if(o2)cout<<iz1*if2;/////////
else cout<<iz1*if2;////////
}
}
else{
if(o1){
if(o2)cout<<0;
}else{
if(o2)cout<<0;
}
}
}
}
}else{
if(z2){
if(f1){
if(f2){
if(o1){
if(o2)cout<<0;
else cout<<0;
}else{
if(o2)cout<<af1*az2;///////
else cout<<af1*az2;/////////
}
}
else{
if(o1){
if(o2)cout<<0;
else cout<<0;
}else{
if(o2)cout<<af1*az2;/////////
else cout<<af1*az2;////////
}
}
}else{
if(f2){
if(o1){
if(o2)cout<<0;
else cout<<0;
}
}
else{
if(o1){
if(o2)cout<<0;
else cout<<0;
}
}
}
}else{
if(f1){
if(f2){
if(o1){
if(o2)cout<<0;
else cout<<if1*af2;
}else{
if(o2)cout<<0;
else cout<<if1*af2;
}
}
else{
if(o1){
if(o2)cout<<0;
}else{
if(o2)cout<<0;
}
}
}else{
if(f2){
if(o1){
if(o2)cout<<0;
else cout<<0;
}
}
else{
if(o1){
if(o2)cout<<0;
}
}
}
}
}
cout<<endl;
f1=0,f2=0,o1=0,o2=0;
z1=0,z2=0;
}
}