General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
165448866 Practice:
rsegvic
1709D - 11 C++14 (GCC 6-32) Time limit exceeded on test 11 2000 ms 79064 KB 2022-07-23 19:41:30 2022-07-23 19:41:30
→ Source
#include<bits/stdc++.h>

using namespace std;

int n, m;
int q;
int a[200000];
int st[200000][100];

void build(){
    for (int i = m-2; i > -1; --i){
        int pot = 1;
        while ((i+(1<<pot)) < m){
            st[i][pot] = max(st[i][pot-1], st[i+(1<<(pot-1))][pot-1]);
            ++pot;
        }
    }
}

int query(int l, int r, int val){
    int poz = l;
    int pot = 20;
    int res = 0;

    while (poz <= r && pot > -1){
        if ((poz + (1<<pot)) <= r){
            res = max (res, st[poz][pot]);
            if (res >= val)return 1;
            poz += 1<<pot;
        }
        pot--;
    }
    return max(res, a[r])>=val;
}

int main()
{
    cin >>n >>m;
    for (int i = 0; i < m; ++i){
        cin >>a[i];
        st[i][0] = a[i];
    }
    build();
    cin >>q;
    for (int i = 0; i < q; ++i){
        int x1, x2, y1, y2, k;
        cin >>x1 >>y1 >>x2 >>y2 >>k;
        if (y1%k != y2%k || x1%k != x2%k){
            cout <<"NO\n";
            continue;
        }
        if (x1 <= a[y1-1] || x2 <= a[y2-1]){
            cout <<"NO\n";
            continue;
        }

        int h = x1+((n-x1)/k)*k;

        ///cout <<maxi <<" " <<h <<"\n";
        if (query(min(y1, y2)-1, max(y1, y2)-1, h)){
            cout <<"NO\n";
            continue;
        }
        cout <<"YES\n";
    }
return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details