-
Notifications
You must be signed in to change notification settings - Fork 1
/
11665.cpp
39 lines (33 loc) · 966 Bytes
/
11665.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
typedef struct Point {
int x, y, z;
Point(int x=0, int y=0, int z=0): x(x), y(y), z(z) {}
} Point;
void solve(void) {
int n; cin >> n;
pair<Point, Point> box = make_pair(Point(1, 1, 1), Point(1000, 1000, 1000));
for (int i=0; i<n; i++) {
Point a, b; cin >> a.x >> a.y >> a.z >> b.x >> b.y >> b.z;
box.first.x = max(box.first.x, a.x);
box.first.y = max(box.first.y, a.y);
box.first.z = max(box.first.z, a.z);
box.second.x = min(box.second.x, b.x);
box.second.y = min(box.second.y, b.y);
box.second.z = min(box.second.z, b.z);
}
int dx = box.second.x - box.first.x;
int dy = box.second.y - box.first.y;
int dz = box.second.z - box.first.z;
int volume = dx * dy * dz;
if (dx < 0 || dy < 0 || dz < 0) volume = 0;
cout << volume << "\n";
}
int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}