# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1042009 | 2024-08-02T12:07:10 Z | PM1 | ZIGZAG (INOI20_zigzag) | C++17 | 2000 ms | 3652 KB |
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second #define ll long long const int mxn=3e5+5,szz=(1<<20); ll n,q,a[mxn]; int main(){ cin>>n>>q; for(int i=1;i<=n;i++){ cin>>a[i]; } while(q--){ int l,r,z; char ty; cin>>ty; if(ty=='\\') cin>>ty; cin>>l>>r; if(ty=='+'){ cin>>z; for(int i=l;i<=r;i++) a[i]+=z; } else if(ty=='?'){ ll ans=0,last,cnt=0; for(int i=l;i<=r;i++){ if(cnt==0){ ans++; cnt++; } else if(a[i-1]==a[i]){ cnt=1; } else if(cnt>1){ if(a[i-2]<=a[i-1] && a[i-1]>a[i]){ ans+=cnt+1; cnt++; } else if(a[i-2]>=a[i-1] && a[i-1]<a[i]){ ans+=cnt+1; cnt++; } else{ ans+=2; cnt=2; } } else{ ans+=2; cnt++; } } cout<<ans<<'\n'; } else{ for(int i=l;i<=r;i++) a[i]*=-1; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2047 ms | 3652 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |