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;
typedef long long ll;
ll n, m, k, t;
ll d[1007][1007];
char a[1007][1007];
void clear_me(){
for(int i = 0; i <= n; i++)
for(int j = 0; j <= m;j ++)
d[i][j] = 0;
}
int main(){
cin >> n >> m >> k;
if(n > 5007 || m > 5007){
map<ll, set<ll>>mp;
for(int i = 0; i < k; i++){
ll o, p;
cin >> o >> p;
mp[o].insert(p);
}
cin >> t;
while(t--){
ll x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if(y2 < y1){
cout << "No" << endl;
continue;
}
auto u = lower_bound(mp[x1].begin(), mp[x1].end(), y1);
if(u == mp[x1].end())
cout << "No" << endl;
else{
ll p = *u;
if(p > y2)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
}
return 0;
}
for(int i = 0; i <= n; i++)
for(int j = 0; j <= m; j++)
a[i][j] = 'B';
for(int i = 0; i < k; i++){
ll aa, bb;
cin >> aa >> bb;
a[aa][bb] = 'G';
}
cin >> t;
while(t--){
clear_me();
ll x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
d[x1][y1] = 1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(d[i][j - 1] == 1 || (a[i - 1][j] == 'G' && d[i - 1][j] == 1))
d[i][j] = 1;
}
}
if(d[x2][y2] == 1)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
# | 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... |