# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1042010 | 2024-08-02T12:08:07 Z | PM1 | ZIGZAG (INOI20_zigzag) | C++17 | 2000 ms | 3668 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; ans++; } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 344 KB | Output is correct |
2 | Correct | 10 ms | 604 KB | Output is correct |
3 | Correct | 13 ms | 564 KB | Output is correct |
4 | Correct | 14 ms | 604 KB | Output is correct |
5 | Correct | 11 ms | 564 KB | Output is correct |
6 | Correct | 3 ms | 348 KB | Output is correct |
7 | Correct | 24 ms | 608 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2024 ms | 2648 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 344 KB | Output is correct |
2 | Correct | 10 ms | 604 KB | Output is correct |
3 | Correct | 13 ms | 564 KB | Output is correct |
4 | Correct | 14 ms | 604 KB | Output is correct |
5 | Correct | 11 ms | 564 KB | Output is correct |
6 | Correct | 3 ms | 348 KB | Output is correct |
7 | Correct | 24 ms | 608 KB | Output is correct |
8 | Execution timed out | 2070 ms | 3668 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 344 KB | Output is correct |
2 | Correct | 10 ms | 604 KB | Output is correct |
3 | Correct | 13 ms | 564 KB | Output is correct |
4 | Correct | 14 ms | 604 KB | Output is correct |
5 | Correct | 11 ms | 564 KB | Output is correct |
6 | Correct | 3 ms | 348 KB | Output is correct |
7 | Correct | 24 ms | 608 KB | Output is correct |
8 | Execution timed out | 2024 ms | 2648 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |