Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <string>
  4. #include <vector>
  5. #include <set>
  6. #include <algorithm>
  7. #include <bitset>
  8. typedef long long LL;
  9. using namespace std;
  10. int main()
  11. {
  12.     int p,q,l,r;
  13.     cin>>p>>q>>l>>r;
  14.     vector<pair<int,int>> a;
  15.     vector<pair<int,int>> b;
  16.     int temp1,temp2;
  17.     int cnt=0;
  18.     for(int i=0;i<p;i++)
  19.     {
  20.         cin>>temp1>>temp2;
  21.         a.push_back(make_pair(temp1,temp2));
  22.     }
  23.     for(int i=0;i<q;i++)
  24.     {
  25.         cin>>temp1>>temp2;
  26.         b.push_back(make_pair(temp1,temp2));
  27.     }
  28.     for(int i=l;i<=r;i++)
  29.     {
  30.         for(int j=0;j<b.size();j++)
  31.         {
  32.             for(int k=0;k<a.size();k++)
  33.             {
  34.                 if((b[j].first+i>=a[k].first && b[j].first+i<=a[k].second) || (b[j].second+i>=a[k].first && b[j].second+i<=a[k].second))
  35.                     cnt++;
  36.             }
  37.         }
  38.     }
  39.     cout<<cnt;
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement