Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Golam Rahman Tushar
- ........Aust Cse 27th batch.........
- */
- //{ Template
- //{ C-headers
- #include <cstdio>
- #include <cstdlib>
- #include <cmath>
- #include <cstring>
- #include <climits>
- #include <cfloat>
- #include <cctype>
- #include <cassert>
- #include <ctime>
- //}
- //{ C++-headers
- #include <iostream>
- #include <iomanip>
- #include <sstream>
- #include <algorithm>
- #include <utility>
- #include <string>
- #include <stack>
- #include <queue>
- #include <vector>
- #include <set>
- #include <map>
- using namespace std;
- //}
- //}
- //{ Floating-points
- #define EPS DBL_EPSILON
- #define abs(x) (((x) < 0) ? - (x) : (x))
- #define zero(x) (abs (x) < EPS)
- #define equal(a,b) (zero ((a) - (b)))
- #define PI 2 * acos (0.0)
- //}
- #define INF 1<<29
- #define ll long long
- template <typename T>
- std::string to_string(T const& value) {
- stringstream sstr;
- sstr << value;
- return sstr.str();
- }
- //}
- template <class T> T gcd(T a,T b){if(b==0) return a;else return gcd(b,a%b);}
- template <class T> T lcm(T a,T b){return (a*b)/gcd(a,b);}
- template <class T> T power( T a, T b){if(b==0) return 1; T x=a;for(T i=2;i<=b;i++) a=a*x;return a;}
- template <class T> T BigMod(T a,T b,T c){if(a==0) return 0;if(b==0) return 1;if(b%2==0){T x=BigMod(a,b/2,c)%c;return (x*x)%c;}else return ((a%c)*BigMod(a,b-1,c)%c)%c;}
- int a[57], b[57], c[57], d[57];
- int main ()
- {
- //freopen("input.txt","r",stdin);
- int p, q, l, r;
- while(cin>>p>>q>>l>>r) {
- int i , j, k;
- for(i=0;i<p;i++) {
- cin>>a[i]>>b[i];
- }
- for(i=0;i<q;i++) {
- cin>>c[i]>>d[i];
- }
- int cnt= 0;
- for(i=l;i<=r;i++) {
- bool flag = true;
- for(j=0;j<q&&flag;j++) {
- for(k=0;k<p&&flag;k++)
- if(((c[j]+i)>=a[k]&&(c[j]+i)<=b[k])||((d[j]+i)>=a[k]&&(d[j]+i)<=b[k])) {
- flag = false; cnt++;
- cout<<i<<endl;
- }
- }
- }
- cout<<cnt<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement