Skip to content

Instantly share code, notes, and snippets.

@fkztw
Created April 29, 2013 20:15
Show Gist options
  • Save fkztw/c92d437af7f7d497de67 to your computer and use it in GitHub Desktop.
Save fkztw/c92d437af7f7d497de67 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cstdlib>
using namespace std;
int main(void)
{
while (true)
{
int n, x, y, z, d;
int x1 = 0, y1 = 0, z1 = 0;
int x2 = 2147483647, y2 = 2147483647, z2 = 2147483647;
cin >> n;
if (n == 0) break;
while (n)
{
cin >> x >> y >> z >> d;
x1 = max(x1, x);
y1 = max(y1, y);
z1 = max(z1, z);
x2 = min(x2, x+d);
y2 = min(y2, y+d);
z2 = min(z2, z+d);
n--;
}
if ( (x1 >= x2) || (y1 >= y2) || (z1 >= z2) ) cout << "0" << endl;
else
{
int r = abs(x2-x1) * abs(y2-y1) * abs(z2-z1);
cout << r << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment