Iamtui1010

pin.cpp

Jan 13th, 2022
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<vector>
  4.  
  5. #define long long long
  6. #define nln '\n'
  7. #define rtg pair<pair<long, long>, pair<long, long>>
  8.  
  9. using namespace std;
  10.  
  11. bool common(const rtg &a, const rtg &b)
  12. {
  13.     if (a.second.first <= b.first.first || a.second.second <= b.first.second)
  14.         return 0;
  15.     if (a.first.first >= b.second.first || a.first.second >= b.second.second)
  16.         return 0;
  17.     return 1;
  18. }
  19.  
  20. int main()
  21. {
  22.     cin.tie(0)->sync_with_stdio(0);
  23.     cout.tie(0)->sync_with_stdio(0);
  24.     //freopen("pin.inp", "r", stdin);
  25.     long n;
  26.     cin >> n;
  27.     vector<rtg> a(n);
  28.     for (auto &i : a)
  29.         cin >> i.first.first >> i.first.second >> i.second.first >> i.second.second;
  30.     // Process
  31.     long ans = 0;
  32.     for (long i = 0; i < n; ++i)
  33.         for (long j = i+1; j < n; ++j)
  34.             if (common(a[i], a[j]))
  35.                 ++ans;
  36.     cout << ans << nln;
  37.     return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment