ivolff

Untitled

Apr 11th, 2020
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <string>
  5. #include <string.h>
  6. #include <vector>
  7. #include <stack>
  8. #include <queue>
  9. #include <deque>
  10. #include <set>
  11. #include <map>
  12. #include <assert.h>
  13. #include <algorithm>
  14. #include <iomanip>
  15. #include <time.h>
  16. #include <math.h>
  17. #include <bitset>
  18. #include <fstream>
  19.  
  20. #define int uint64_t
  21.  
  22. using namespace std;
  23.  
  24. int32_t main() {
  25.     ios_base::sync_with_stdio(false);
  26.     set<pair<int,int>> data;
  27.     vector<pair<int,int>> data2;
  28.     int n,xa,ya;
  29.     cin >> n;
  30.     for (int i = 0; i < n; i++) {
  31.         cin >> xa >> ya;
  32.         data.emplace(xa,ya);
  33.         data2.emplace_back(xa,ya);
  34.     }
  35.     int counter = 0;
  36.     for (int i = 0; i < n; i++) {
  37.         auto x = data.upper_bound({data2[i].first, 0});
  38.         auto y = data.upper_bound({data2[i].second, 0});
  39.         bool flag = true;
  40.         while (x != data.end()) {
  41.             if (x->second > data2[i].second){
  42.                 flag = false;
  43.                 break;
  44.             }
  45.             x++;
  46.         }
  47.         while (y != data.end() && flag) {
  48.             if (y->second > data2[i].first){
  49.                 flag = false;
  50.                 break;
  51.             }
  52.             y++;
  53.         }
  54.         counter += flag;
  55.     }
  56.     cout << counter;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment