C++/백준 C++
[백준]C++ 2669 직사각형 네개의 합집합의 면적 구하기 [구현]
CE : 하랑
2024. 11. 17. 20:35
코드
#include <iostream>
#include <vector>
int main()
{
std::vector<std::vector<int>> boards;
boards.resize(101);
for (int i = 0; i < boards.size(); i++)
{
boards[i].resize(101);
}
int count = 0;
for (int i = 0; i < 4; i++)
{
int x1, y1, x2, y2;
std::cin >> x1 >> y1 >> x2 >> y2;
for (int y = y1; y < y2; y++)
{
for (int x = x1; x <x2; x++)
{
++boards[y][x];
if (boards[y][x] == 1)
{
++count;
}
}
}
}
std::cout << count<<"\n";
return 0;
}