Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <algorithm>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <string>
- #include <set>
- #include <cmath>
- #include <map>
- #include <unordered_map>
- #include <numeric>
- #include <random>
- #include <memory>
- #include <chrono>
- #include <functional>
- #include <unordered_set>
- #include <cstring>
- #include <cassert>
- #include <bitset>
- #ifdef LOCAL
- #include "debug.h"
- #else
- #define debug(x...)
- #endif
- //#define int ll
- //#pragma GCC optimize("Ofast")
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef pair <int, int> pii;
- typedef pair <ll, ll> pll;
- #define sz(x) int((x).size())
- mt19937 rng(229);
- const int N = 1.5e5 + 7;
- const int inf = INT_MAX / 2;
- const ll INF = LLONG_MAX / 3;
- const int MOD = 998244353;
- const ld eps = 1e-6;
- const string cars[] = {"🚗", "🚕", "🚙"};
- int n, m, k;
- unordered_map < int, vector < int > > a;
- vector < int > xx;
- signed main() {
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- cout << fixed << setprecision(9);
- ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
- // n - floors
- // m - plates
- cin >> n >> m >> k;
- for (int i = 0; i < k; i++) {
- int x, y;
- // x - floor, y - plate
- cin >> x >> y;
- a[x].push_back(y);
- xx.push_back(x);
- }
- sort(xx.begin(), xx.end());
- xx.erase(unique(xx.begin(), xx.end()), xx.end());
- for (auto &[x, y] : a) {
- sort(y.begin(), y.end());
- }
- int q;
- cin >> q;
- while (q--) {
- int x1, y1, x2, y2;
- cin >> x1 >> y1 >> x2 >> y2;
- if (x2 < x1) {
- cout << "No\n";
- continue;
- }
- if (x1 == x2) {
- cout << "Yes\n";
- continue;
- }
- /*
- if (x2 - x1 > 5e3 + 2) {
- cout << "No\n";
- continue;
- }*/
- int y = y1;
- bool flag = true;
- for (int i = x1; i < x2 && flag; i++) {
- auto ptr = lower_bound(a[i].begin(), a[i].end(), y);
- if (ptr == a[i].end()) {
- flag = false;
- }
- else {
- y = *ptr;
- }
- }
- if (flag && y <= y2) {
- cout << "Yes\n";
- }
- else {
- cout << "No\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement