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;
#define int long long
signed main()
{
int R, C, N, a, b, prev = -1, val = -1, T, c, d, tem;
cin >> R >> C >> N;
vector<int> compr;
set<int> finding;
map<int, int> revCompr;
vector<set<int>> green;
set<pair<int, int>> queued;
bool done = false;
for (int i = 0; i < N; i++)
{
cin >> a >> b;
a--, b--;
queued.insert(pair<int, int>(b, a));
finding.insert(a);
}
auto iter = queued.begin();
for (int i = 0; i < N; i++)
{
if (iter->first != prev)
{
prev = iter->first;
compr.push_back(prev);
val++;
revCompr[prev] = val;
green.push_back(set<int>());
}
green[val].insert(iter->second);
iter++;
}
cin >> T;
for (int i = 0; i < T; i++)
{
done = false;
cin >> a >> b >> c >> d;
a--, b--, c--, d--;
tem = b;
b = a;
a = tem;
tem = d;
d = c;
c = tem;
if (a > c || b > d)
{
cout << "No\n";
continue;
}
while (b != d && a <= c)
{
if (finding.lower_bound(b) == finding.end() || *finding.lower_bound(b) != b)
{
cout << "No\n";
done = true;
break;
}
if (green[revCompr[b]].lower_bound(a) == green[revCompr[b]].end())
{
cout << "No\n";
done = true;
break;
}
a = *green[revCompr[b]].lower_bound(a);
b++;
}
if (done)
continue;
if (a > c)
cout << "No\n";
else
cout << "Yes\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... |