#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
// #define s second
#define pb(x) push_back(x)
#define int long long
const int MOD = 1e9+7;
const int inf = 1e9;
const int INF = 1e18+20;
const int LOG = 25;
int n;
vector<int> a;
int tt (int l, int r) {
int len = r-l+1;
if (len==1) return len;
int ans=2;
int L=l;
for (int R=l+1; R<=r; R++) {
if (R==L+1) continue;
if (a[R] - a[R-1] != a[L+1] - a[L]) {
L=R-1;
}
ans = max(ans, R-L+1);
}
return ans;
}
/*
l=1, r=n. after a rewrite information the answer is
always n and before a rewrite the answer is always
the answer in original array
*/
void solve() {
int q;
cin>>n>>q;
a.resize(n);
for (int i=0; i<n; i++) {
cin>>a[i];
}
int before = tt(0, n-1);
bool seen=false;
while (q--) {
int type;
cin>>type;
if (type==1) {
int l, r, s, c;
cin>>l>>r>>s>>c;
l--; r--;
/*for (int i=l; i<=r; i++) {
a[i]+= (s + (i-l)*c);
}*/
} else if (type == 2) {
int l, r, s, c;
cin>>l>>r>>s>>c;
l--; r--;
/*for (int i=l; i<=r; i++) {
a[i] = (s + (i-l)*c);
}*/
seen=true;
} else {
int l, r;
cin>>l>>r;
l--; r--;
cout<<(seen ? n : before)<<endl;
}
}
}
bool multi=false;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t=1;
if (multi) cin>>t;
while (t--) solve();
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |