Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- ll n,m;
- cin >> n >> m;
- vector<pair<int,int>>vv;
- while (n--) {
- int l,r;
- cin >> l >> r;
- vv.push_back({l,r});
- }
- sort(vv.begin(), vv.end());
- vector<pair<int,int>>v;
- for (auto &i:vv) {
- if (v.empty() || v.back().second<i.first) {
- v.push_back(i);
- }
- else v.back().second=max(i.second,v.back().second);
- }
- // for (int i=0; i<v.size(); i++) {
- // cout << v[i].first << " " << v[i].second << endl;
- // }
- int q;
- cin >> q;
- while (q--) {
- int u,x;
- cin >> u >> x;
- if (x<u) swap(x,u);
- int f=0;
- for (auto i:v) {
- if (u>=i.first && x<=i.second) {
- cout << "YES" << endl;
- f=1;
- break;
- }
- }
- if (!f) cout << "NO" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment