Advertisement
aayyk

Untitled

May 11th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdlib>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <queue>
  7. #include <stack>
  8. #include <climits>
  9. #include <string>
  10. #include <set>
  11. #include <cmath>
  12. #include <map>
  13. #include <unordered_map>
  14. #include <numeric>
  15. #include <random>
  16. #include <memory>
  17. #include <chrono>
  18. #include <functional>
  19. #include <unordered_set>
  20. #include <cstring>
  21. #include <cassert>
  22. #include <bitset>
  23. #ifdef LOCAL
  24. #include "debug.h"
  25. #else
  26. #define debug(x...)
  27. #endif
  28. //#define int ll
  29. //#pragma GCC optimize("Ofast")
  30.  
  31. using namespace std;
  32. typedef long long ll;
  33. typedef long double ld;
  34. typedef pair <int, int> pii;
  35. typedef pair <ll, ll> pll;
  36. #define sz(x) int((x).size())
  37.  
  38. mt19937 rng(229);
  39.  
  40. const int N = 1.5e5 + 7;
  41. const int inf = INT_MAX / 2;
  42. const ll INF = LLONG_MAX / 3;
  43. const int MOD = 998244353;
  44. const ld eps = 1e-6;
  45. const string cars[] = {"🚗", "🚕", "🚙"};
  46.  
  47. int n, m, k;
  48. unordered_map < int, vector < int > > a;
  49. vector < int > xx;
  50.  
  51. signed main() {
  52. #ifdef LOCAL
  53.     freopen("input.txt", "r", stdin);
  54.     freopen("output.txt", "w", stdout);
  55. #endif
  56.     cout << fixed << setprecision(9);
  57.     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  58.  
  59.     // n - floors
  60.     // m - plates
  61.  
  62.     cin >> n >> m >> k;
  63.  
  64.     for (int i = 0; i < k; i++) {
  65.         int x, y;
  66.         // x - floor, y - plate
  67.         cin >> x >> y;
  68.  
  69.         a[x].push_back(y);
  70.         xx.push_back(x);
  71.     }
  72.     sort(xx.begin(), xx.end());
  73.     xx.erase(unique(xx.begin(), xx.end()), xx.end());
  74.  
  75.     for (auto &[x, y] : a) {
  76.         sort(y.begin(), y.end());
  77.     }
  78.  
  79.     int q;
  80.     cin >> q;
  81.  
  82.     while (q--) {
  83.         int x1, y1, x2, y2;
  84.         cin >> x1 >> y1 >> x2 >> y2;
  85.  
  86.         if (x2 < x1) {
  87.             cout << "No\n";
  88.             continue;
  89.         }
  90.         if (x1 == x2) {
  91.             cout << "Yes\n";
  92.             continue;
  93.         }
  94.         /*
  95.         if (x2 - x1 > 5e3 + 2) {
  96.             cout << "No\n";
  97.             continue;
  98.         }*/
  99.         int y = y1;
  100.         bool flag = true;
  101.         for (int i = x1; i < x2 && flag; i++) {
  102.             auto ptr = lower_bound(a[i].begin(), a[i].end(), y);
  103.             if (ptr == a[i].end()) {
  104.                 flag = false;
  105.             }
  106.             else {
  107.                 y = *ptr;
  108.             }
  109.         }
  110.         if (flag && y <= y2) {
  111.             cout << "Yes\n";
  112.         }
  113.         else {
  114.             cout << "No\n";
  115.         }
  116.     }
  117.  
  118.     return 0;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement