Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve()
- {
- ll H, C, Q;
- cin >> H >> C >> Q;
- vector<vector<ll>> HSE;
- vector<vector<ll>> L, R;
- for (ll i = 0; i < C; i++)
- {
- ll h, s, e;
- cin >> h >> s >> e;
- HSE.push_back({h, s, e});
- L.push_back({s, h});
- R.push_back({e + 1, h});
- }
- sort(L.begin(), L.end());
- sort(R.begin(), R.end());
- vector<vector<ll>> HTI;
- for (ll q = 0; q < Q; q++)
- {
- ll h, t;
- cin >> h >> t;
- HTI.push_back({h, t, q});
- }
- sort(HTI.begin(), HTI.end(), [](const vector<ll> &a, const vector<ll> &b) { return a[1] < b[1]; });
- multiset<ll> currentHeights;
- vector<string> ans(Q, "NO");
- ll l = 0, r = 0;
- for (ll q = 0; q < Q; q++)
- {
- // add useful heights
- while (l < C && L[l][0] <= HTI[q][1])
- {
- currentHeights.insert(L[l][1]);
- l++;
- }
- // remove useless heights;
- while (r < C && R[r][0] <= HTI[q][1])
- {
- currentHeights.erase(currentHeights.find(R[r][1]));
- r++;
- }
- if (currentHeights.size() == 0 || HTI[q][0] > *currentHeights.rbegin())
- {
- ans[HTI[q][2]] = "YES";
- }
- }
- for (ll i = 0; i < Q; i++)
- {
- cout << ans[i] << endl;
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement