Submission #739733

# Submission time Handle Problem Language Result Execution time Memory
739733 2023-05-11T07:32:12 Z KareemBenzeema Alternating Heights (CCO22_day1problem1) C++17
0 / 25
1000 ms 1204 KB
///     This code was written by KareemBenzeema
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fast ios_base::sync_with_stdio(0) ;cin.tie(0) ; cout.tie(0) ;
#define pf push_front
#define pob pop_back
#define pof pop_front
#define gcd __gcd
#define mod (ll) 1e6+3
#define inf (ll) 1e9+9
#define all(x) (x).begin(),(x).end()
#define len(x) (int)(x).size()
#define endl '\n'

using namespace std ;
inline void setio(string ) ;

int main()
{
    fast ;
    int n , k , q ; cin>>n>>k>>q ;
    int arr[n+2] ;
    for (int i=0;i<n;i++) cin>>arr[i] ;
    for (;q--;){
        int l , r ; cin>>l>>r ;
        bool ans = true ;
        map <pair <int,int>,bool> even , odd ;
        for (;l<r;){
            if (arr[l]==arr[l-1]) ans = false ;
            if (l%2==0){
                if (odd[{arr[l],arr[l-1]}]) ans = false ;
                even[{arr[l],arr[l-1]}] = true ;
            }
            else {
                if (even[{arr[l],arr[l-1]}]) ans = false ;
                odd[{arr[l],arr[l-1]}] = true ;
            }
            l++ ;
        }
        cout<<(ans ? "YES" : "NO")<<endl ;
    }
    return 0 ;
}

inline void setio(string s)
{
    freopen((s+".in").c_str(),"r",stdin) ;
    freopen((s+".out").c_str(),"w",stdout) ;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 1080 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 1204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 488 ms 704 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 1080 KB Time limit exceeded
2 Halted 0 ms 0 KB -