Submission #690891

#TimeUsernameProblemLanguageResultExecution timeMemory
690891TomitaMateiTrampoline (info1cup20_trampoline)C++14
62 / 100
2101 ms2560 KiB
#include <iostream>
#include <algorithm>
using namespace std;
struct pozitii
{
    int x,y;
}poz[200001];

bool ord (pozitii a, pozitii b)
{
    return  a.x<b.x || (a.x==b.x && a.y<b.y);
}

int n,k,i,m,t,x1,y1,x2,y2,mij,st,dr,ok;
int main()
{
    cin>>n>>m>>k;
    for (i=1; i<=k; i++)
    cin>>poz[i].x>>poz[i].y;

    sort (poz+1,poz+k+1,ord);

    cin>>t;
    while (t!=0)
    {
        t--;
        cin>>x1>>y1>>x2>>y2;

        st=1;
        dr=k;
        while (st<=dr)
        {
            mij=(st+dr)/2;
            if (poz[mij].x==x1) break;
            if (poz[mij].x>x1) dr=mij-1;
            else st=mij+1;
        }

        while (poz[mij-1].x==poz[mij].x) mij--;


        while (x2!=x1 && poz[mij].x<=x1)
        {
            if (poz[mij].x==x1 && poz[mij].y>=y1)
            {
                x1++;
                y1=poz[mij].y;
                if (y1>y2)
                    break;

            }

            mij++;
        }


        if (x2==x1 && y1<=y2)
            cout<<"Yes";
        else cout<<"No";
        cout<<'\n';

    }


    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...