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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int maxn = 200005;
int r, c, n;
pair<int, int> a[maxn];
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> r >> c >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i].first >> a[i].second;
}
sort(a + 1, a + n + 1);
int q;
cin >> q;
for (int i = 1; i <= q; ++i)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 > x2 || y1 > y2)
{
cout << "No\n";
continue;
}
if (x1 == x2)
{
cout << "Yes\n";
continue;
}
int l = 1;
int r = n;
while (l <= r)
{
int mid = (l + r) / 2;
if (a[mid] >= make_pair(x1, y1))
{
r = mid - 1;
}
else
{
l = mid + 1;
}
}
if (l == n + 1)
{
cout << "No\n";
continue;
}
if (a[l].first != x1)
{
cout << "No\n";
continue;
}
pair<int, int> curr = a[l];
for (int j = l + 1; j <= n; ++j)
{
if (a[j].first > curr.first + 1)
{
cout << "No\n";
break;
}
if (a[j].first == curr.first + 1)
{
if (a[j].second > curr.second)
{
curr = a[j];
if (curr.first + 1 == x2)
{
if (curr.second > y2)
{
cout << "No\n";
break;
}
cout << "Yes\n";
break;
}
else if (curr.second > y2)
{
cout << "No\n";
break;
}
}
}
}
}
return 0;
}
/*
4 5 2
2 2
3 4
1
2 1 4 5
*/
# | 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... |