This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int nx=2e5+5, kx=18;
int r, c, n, q, p[4], pa[nx][kx], x[nx], y[nx];
map<int, set<pair<int, int>>> mp;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>r>>c>>n;
for (int i=1; i<=n; i++) cin>>x[i]>>y[i], mp[x[i]].insert({y[i], i});
for (int i=1; i<=n; i++)
{
if (mp.find(x[i]+1)==mp.end()||mp[x[i]+1].lower_bound(make_pair(y[i], 0))==mp[x[i]+1].end()) pa[i][0]=i;
else pa[i][0]=mp[x[i]+1].lower_bound(make_pair(y[i], 0))->second;
}
for (int i=1; i<kx; i++) for (int j=1; j<=n; j++) pa[j][i]=pa[pa[j][i-1]][i-1];
cin>>q;
while (q--)
{
cin>>p[0]>>p[1]>>p[2]>>p[3];
if (p[0]>p[2]) cout<<"No\n";
else if (p[1]>p[3]) cout<<"No\n";
else if (p[0]==p[2]) cout<<"Yes\n";
else if (mp.find(p[0])==mp.end()||mp[p[0]].lower_bound(make_pair(p[1], 0))==mp[p[0]].end()) cout<<"No\n";
else
{
int st=mp[p[0]].lower_bound(make_pair(p[1], 0))->second;
for (int i=kx-1; i>=0; i--) if (x[pa[st][i]]<p[2]) st=pa[st][i];
if (x[st]!=p[2]-1) cout<<"No\n";
else if (y[st]<=p[3]) cout<<"Yes\n";
else cout<<"No\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |