Advertisement
Guest User

Chef and the Cake I

a guest
Aug 21st, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. //Bismillahir Rahmanir Rahim
  2. /******Harun Or Rashid******/
  3. /***********Template Starts Here***********/
  4. #include<iostream>
  5. #include<cstdio>
  6. #include<cstring>
  7. #include<cmath>
  8. #include<cctype>
  9. #include<cstdlib>
  10. #include<string>
  11. #include<vector>
  12. #include<set>
  13. #include<stack>
  14. #include<queue>
  15. #include<map>
  16. #include<algorithm>
  17. using namespace std;
  18.  
  19. #define MEM(a,b) memset(a,b,sizeof(a))
  20. #define CLR(a) memset(a,0,sizeof(a))
  21. #define MAX(a,b) ((a)>(b)?(a):(b))
  22. #define MIN(a,b) ((a)>(b)?(b):(a))
  23. #define ABS(a) ((a)>0? (a):(-(a)))
  24. #define SQ(a) ((a)*(a))
  25. #define SZ(a) (int)a.size()
  26. #define FORN(i,n) for(i=1;i<=n;i++)
  27. #define FORAB(i,a,b) for(i=a;i<=b;i++)
  28. #define ALL(V) V.begin(),V.end()
  29. #define pb(a) push_back(a)
  30. #define pr(a) cout<<a<<endl
  31. #define pf printf
  32. #define sf scanf
  33. #define swap(a,b) (a ^= b, b ^= a, a ^= b)
  34. #define PI acos(-1)
  35. #define x first
  36. #define y second
  37. #define eps 1e-7
  38.  
  39. typedef int D;
  40. typedef long long int LLD;
  41. typedef unsigned long long int LLU;
  42. typedef vector<D> VI;
  43. typedef set<D> SI;
  44. typedef vector<D>::iterator Viti;
  45.  
  46. /***********Template Ends Here***********/
  47.  
  48. int main()
  49. {
  50.     int T,x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,result;
  51.     cin>>T;
  52.     while(T--)
  53.     {
  54.         cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
  55.         result=0;
  56.         x5=(x1>x3)?x1:x3;
  57.         y5=(y1>y3)?y1:y3;
  58.         x6=(x2>x4)?x4:x2;
  59.         y6=(y2>y4)?y4:y2;
  60.         result+=(x2-x1)*(y2-y1)+(x4-x3)*(y4-y3);
  61.         if(x6>x5 && y6>y5)
  62.             result-=(x6-x5)*(y6-y5);
  63.         cout<<result<<endl;
  64.     }
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement