- 문제 링크 : http://boj.kr/11665
- 난이도 : S5
- 태그 : 기하학
코드
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define INF 0x7FFFFFFF
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
pii x, y, z;
x = y = z = {0, INF};
for(int i = 0; i < n; i++) {
int x1, y1, z1, x2, y2, z2;
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
x.first = max(x.first, x1);
x.second = min(x.second, x2);
y.first = max(y.first, y1);
y.second = min(y.second, y2);
z.first = max(z.first, z1);
z.second = min(z.second, z2);
}
cout << max(0, x.second-x.first) * max(0, y.second-y.first) * max(0, z.second-z.first);
return 0;
}
풀이
각 축은 결과에서 독립적이다.
각 축의 겹치는 부분은 수직선 위의 겹치는 구간과 동일하다.
728x90
'PS' 카테고리의 다른 글
BOJ 15887 : 욱제는 결벽증이야!! (0) | 2025.01.18 |
---|---|
BOJ 1059 : 좋은 구간 (0) | 2025.01.17 |
BOJ 2346 : 풍선 터뜨리기 (0) | 2025.01.15 |
BOJ 33011 : 홀수와 짝수 게임 (0) | 2025.01.14 |
BOJ 21030 : Frequent Alphabet (0) | 2025.01.13 |