比赛 |
CSP2022提高组 |
评测结果 |
AAAAAAAAAAAATTTTTTTT |
题目名称 |
策略游戏 |
最终得分 |
60 |
用户昵称 |
Lesater |
运行时间 |
8.000 s |
代码语言 |
C++ |
内存使用 |
2.90 MiB |
提交时间 |
2022-10-30 09:51:17 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mm LONG_LONG_MAX
#define nn LONG_LONG_MIN
ll a1[100001],a2[100001];
ll m,n,q,l1,r1,l2,r2;
int main()
{
freopen("csp2022_game.in","r",stdin);
freopen("csp2022_game.out","w",stdout);
cin>>n>>m>>q;
for(int i=1;i<=n;++i)
{
cin>>a1[i];
}
for(int i=1;i<=m;++i)
{
cin>>a2[i];
}
while(q>0)
{
ll a1max_f=nn,a1min_f=1,a1min_z=mm,a1max_z=-1;
ll a2max_f=nn,a2min_f=1,a2min_z=mm,a2max_z=-1;
q--;
cin>>l1>>r1>>l2>>r2;
for(int i=l1;i<=r1;++i)
{
if(a1[i]>=0&&a1[i]<a1min_z)
a1min_z=a1[i];
if(a1[i]<0&&a1[i]>a1max_f)
a1max_f=a1[i];
if(a1[i]>=0&&a1[i]>a1max_z)
a1max_z=a1[i];
if(a1[i]<0&&a1[i]<a1min_f)
a1min_f=a1[i];
}
for(int i=l2;i<=r2;++i)
{
if(a2[i]>=0&&a2[i]<a2min_z)
a2min_z=a2[i];
if(a2[i]<0&&a2[i]>a2max_f)
a2max_f=a2[i];
if(a2[i]>=0&&a2[i]>a2max_z)
a2max_z=a2[i];
if(a2[i]<0&&a2[i]<a2min_f)
a2min_f=a2[i];
}
ll t=nn;
if(a1min_z!=mm&&a2min_f!=1) t=max(t,a1min_z*a2min_f);
if(a1max_f!=nn&&a2max_z!=-1) t=max(t,a1max_f*a2max_z);
if(a1max_z!=-1&&a2min_f==1) t=max(t,a1max_z*a2min_z);
if(a1min_f!=1&&a2max_z==-1) t=max(t,a1min_f*a2max_f);
cout<<t<<endl;
}
return 0;
}