백준 문제풀이/Implementation
[C++] 백준 문제풀이 (Implementation) 2669번 직사각형 네개의 합집합의 면적 구하기
코딩준우
2023. 6. 28. 02:54
https://www.acmicpc.net/problem/2669
2669번: 직사각형 네개의 합집합의 면적 구하기
입력은 네 줄이며, 각 줄은 직사각형의 위치를 나타내는 네 개의 정수로 주어진다. 첫 번째와 두 번째의 정수는 사각형의 왼쪽 아래 꼭짓점의 x좌표, y좌표이고 세 번째와 네 번째의 정수는 사각
www.acmicpc.net
//[C++] 백준 문제풀이 (Implementation)
#include <bits/stdc++.h>
const int MAX = 100;
int map[MAX][MAX];
int a, b, c, d;
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int ret = 0;
for (int i = 0; i < 4; ++i){
std::cin >> a >> b >> c >> d;
for (int y = b; y < d; ++y){
for (int x = a; x < c; ++x){
if (map[y][x] == 0){
++ret;
map[y][x] = 1;
}
}
}
}
std::cout << ret << "\n";
return 0;
}