Advertisement
Valkyrie006

Untitled

Oct 8th, 2021
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. void solve()
  2. {
  3.     ll H, C, Q;
  4.     cin >> H >> C >> Q;
  5.     vector<vector<ll>> HSE;
  6.     vector<vector<ll>> L, R;
  7.     for (ll i = 0; i < C; i++)
  8.     {
  9.         ll h, s, e;
  10.         cin >> h >> s >> e;
  11.         HSE.push_back({h, s, e});
  12.         L.push_back({s, h});
  13.         R.push_back({e + 1, h});
  14.     }
  15.     sort(L.begin(), L.end());
  16.     sort(R.begin(), R.end());
  17.     vector<vector<ll>> HTI;
  18.     for (ll q = 0; q < Q; q++)
  19.     {
  20.         ll h, t;
  21.         cin >> h >> t;
  22.         HTI.push_back({h, t, q});
  23.     }
  24.     sort(HTI.begin(), HTI.end(), [](const vector<ll> &a, const vector<ll> &b) { return a[1] < b[1]; });
  25.     multiset<ll> currentHeights;
  26.     vector<string> ans(Q, "NO");
  27.     ll l = 0, r = 0;
  28.     for (ll q = 0; q < Q; q++)
  29.     {
  30.         // add useful heights
  31.         while (l < C && L[l][0] <= HTI[q][1])
  32.         {
  33.             currentHeights.insert(L[l][1]);
  34.             l++;
  35.         }
  36.         // remove useless heights;
  37.         while (r < C && R[r][0] <= HTI[q][1])
  38.         {
  39.             currentHeights.erase(currentHeights.find(R[r][1]));
  40.             r++;
  41.         }
  42.         if (currentHeights.size() == 0 || HTI[q][0] > *currentHeights.rbegin())
  43.         {
  44.             ans[HTI[q][2]] = "YES";
  45.         }
  46.     }
  47.     for (ll i = 0; i < Q; i++)
  48.     {
  49.         cout << ans[i] << endl;
  50.     }
  51.     return;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement