对拍不出错,50pts求调,3rmb
查看原帖
对拍不出错,50pts求调,3rmb
241867
wtcqwq楼主2022/10/4 07:23
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200009;
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
        x=x*10+ch-'0',ch=getchar();
    return x*f;
}
void write(int x){
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
    return;
}


namespace solv{
	void solve(){

	}
}
void rep(ll T){
	while(T--){
		solv::solve();
	}
}
const ll LMT=(1<<30);
ll n,q,a[N];
int main(){
	freopen("A.in","r",stdin);
	freopen("ABF.out","w",stdout);
//	cout<<LMT<<endl;
	cin>>n>>q;
	for(ll i=1;i<=n;i++) cin>>a[i];
	while(q--){
		ll opt;
		cin>>opt;
		if(opt==1){
			ll i,k; cin>>i>>k;
			a[i]=k;
		}
		else if(opt==2){
			ll l,r; cin>>l>>r;
			if(r-l>100){
				cout<<"Too large"<<endl;
				continue;
			}
			ll cnt=0;
			for(ll i=l;i<=r;i++) if(a[i]<0) cnt++;
			if(cnt%2==0){
				ll ans=1;
				for(ll i=l;i<=r;i++){ans*=abs(a[i]); if(ans>LMT){cout<<"Too large"<<endl; break;}}
				if(ans<LMT) cout<<ans<<endl;
			}
			else{
				ll qwq=l;
				for(ll i=l;i<=r;i++){
					if(a[i]<0){
						qwq=i; break;
					}
				}
				ll ans=1,ans2=1;
				for(ll i=qwq+1;i<=r;i++){
					ans*=abs(a[i]);
					if(ans>LMT){
						cout<<"Too large"<<endl;
						break;
					}
				}
				if(ans>LMT) continue;
				qwq=r;
				for(ll i=r;i>=l;i--){
					if(a[i]<0){
						qwq=i;
						break;
					}
				}
				for(ll i=l;i<qwq;i++){
					ans2*=abs(a[i]);
					if(ans2>LMT){
						cout<<"Too large"<<endl;
						break;
					}
				}
				if(ans2>LMT) continue;
				cout<<max(ans,ans2)<<endl;
			}
		}
	}
	return 0;
}
2022/10/4 07:23
加载中...