#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,tes,t,f[300009],pas,ZX,XC;
char tp;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>tes;
for(i=1; i<=a; i++) cin>>f[i];
for(t=1; t<=tes; t++){
cin>>tp;
if(tp=='*'){
cin>>c>>d;
for(i=c; i<=d; i++) f[i]=-f[i];
continue;
}
if(tp=='+'){
cin>>c>>d>>e;
for(i=c; i<=d; i++){
f[i]+=e;
}
continue;
}
if(tp=='?'){
cin>>c>>d;pas=0;
/*for(i=d; i>=c; i--){
pas++;e=0;
for(j=i-1; j>=c; j--){
if(f[j]==f[j+1]) break;
if(f[j]<f[j+1]){
if(e==-1) break;
e=-1;
}else{
if(e==1) break;
e=1;
}
pas++;
}
}*/
pas=1;
zx=1;xc=1;
for(i=d-1; i>=c; i--){
if(f[i]==f[i+1]){
pas++;
zx=1;xc=1;
//cout<<i<<" "<<pas<<"\n";
continue;
}
pas++;
if(f[i]<f[i+1]){
pas+=xc;
ZX=xc+1;XC=1;
zx=ZX;xc=XC;
}else{
pas+=zx;
ZX=1;XC=zx+1;
zx=ZX;xc=XC;
}
//cout<<i<<" "<<pas<<"\n";
}
cout<<pas<<"\n";
continue;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
340 KB |
Output is correct |
2 |
Correct |
13 ms |
468 KB |
Output is correct |
3 |
Correct |
14 ms |
344 KB |
Output is correct |
4 |
Correct |
13 ms |
464 KB |
Output is correct |
5 |
Correct |
14 ms |
436 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
33 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2091 ms |
2656 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
340 KB |
Output is correct |
2 |
Correct |
13 ms |
468 KB |
Output is correct |
3 |
Correct |
14 ms |
344 KB |
Output is correct |
4 |
Correct |
13 ms |
464 KB |
Output is correct |
5 |
Correct |
14 ms |
436 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
33 ms |
468 KB |
Output is correct |
8 |
Execution timed out |
2058 ms |
2108 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
340 KB |
Output is correct |
2 |
Correct |
13 ms |
468 KB |
Output is correct |
3 |
Correct |
14 ms |
344 KB |
Output is correct |
4 |
Correct |
13 ms |
464 KB |
Output is correct |
5 |
Correct |
14 ms |
436 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
33 ms |
468 KB |
Output is correct |
8 |
Execution timed out |
2091 ms |
2656 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |