Advertisement
ahamed210

Intersection of cube

Nov 4th, 2021
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef int l;
  4. typedef long long int ll;
  5. #define loop(a, b) for(int i = a; i < b; i++)
  6. #define PI acos(-1.0)
  7. const ll INF = LLONG_MAX;
  8.  
  9. const ll mod = 1000000007;
  10. ll gcd(ll a,ll b){ if(b == 0) return a; return gcd(b, a % b); }
  11.  ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
  12. ll power(ll a, ll b){ll res = 1;while(b){if(b&1) res = (res*a)%mod;b>>=1;a = (a*a)%mod;}return res%mod;}
  13. //leftmost set bit
  14. l clz(int N) {return N ? 32 - __builtin_clz(N) : -(1e9+1);}
  15. //ll clz(unsigned long long N){return N ? 64 - __builtin_clzll(N) : -(1e18+1);}
  16. l setbit(l x){return __builtin_popcountll(x);}
  17. //ll power(ll a, ll b){ll res = 1;while(b){if(b&1) res = (res*a);b>>=1;a = (a*a);}return res;}
  18. bool arraySortedOrNot(int arr[], int n){if (n == 0 || n == 1) return true;for (int i = 1; i < n; i++)if (arr[i - 1] > arr[i]) return false;return true;}
  19. // long long v[400002];
  20. // void Quicksort(int begin,int end){
  21. //   int e,b,aux,p;b=begin;e=end;p=v[(e+b)/2];
  22. //   while(v[b]<p){b++;}while(v[e]>p){e--;}while(b<e){aux=v[b];v[b]=v[e];v[e]=aux;do{b++;}while(v[b]<p);
  23. //   do{e--;}while(v[e]>p);}if(begin<e){ Quicksort(begin,e);}
  24. //   if(e+1<end){ Quicksort(e+1,end);}
  25. // }
  26.  
  27. // string decimalToBinary(l n)
  28. // {
  29. //     string s = bitset<64> (n).to_string();
  30. //     const auto loc1 = s.find('1');
  31. //     if(loc1 != string::npos) return s.substr(loc1);
  32. // }
  33.  
  34. void run(){
  35.     ios::sync_with_stdio(false);
  36.     cin.tie(NULL);
  37.     cout.tie(NULL);
  38. #ifndef ONLINE_JUDGE
  39.     freopen("input.txt", "r", stdin);
  40.     freopen("output7.txt", "w", stdout);
  41. #else
  42. #endif
  43. }
  44.  
  45. l o = 1;
  46.  
  47. void solve(){
  48.     l x;cin>>x;
  49.     l a,b,c,d,e,f;
  50.     cin>>a>>b>>c>>d>>e>>f;
  51.     l a1 = a,b1 = b,c1 = c,d1 = d,e1 = e,f1 = f;
  52.     x--;
  53.     l res = 0;
  54.     while(x--){
  55.         cin>>a>>b>>c>>d>>e>>f;
  56.         a1 = max(a1,a);d1 = min(d1,d);
  57.         b1 = max(b1,b);e1 = min(e1,e);
  58.         c1 = max(c1,c);f1 = min(f1,f);
  59.     }
  60.     if(d1-a1 > 0 && e1-b1 > 0 && f1-c1 > 0){
  61.         res = (d1-a1)*(e1-b1)*(f1-c1);
  62.         cout << "Case "<< o++ << ": " << res << endl;
  63.         return;
  64.     }
  65.     cout << "Case "<< o++ << ": " << res << endl;
  66. }
  67.  
  68. int main()
  69. {
  70.     //clock_t tStart = clock();
  71.     run();
  72.     //precal();
  73.     l n;cin>>n;
  74.     while(n--) {solve();}
  75.     //printf("Time taken: %.10fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  76.     return 0;
  77. }
  78.  
  79.  
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement