728x90
2563 색종이


#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int test_case, row = 100, column = 100, ans = 0;
vector<vector<int>> int_arr(row,vector<int>(column));
cin >> test_case;
for (int i = 0; i < test_case; ++i)
{
int witdh, height;
cin >> witdh >> height;
for (int x = witdh; x < witdh + 10; ++x)
{
for (int y = height; y < height + 10; ++y)
{
if (0 == int_arr[x][y])
{
int_arr[x][y] = 1;
ans++;
}
}
}
}
cout << ans;
return 0;
}
- 2차원 배열 0,1을 이용해서 색칠한 부분을 나타내도록 했다.
- 넓이라는 것은 1의 개수를 세면 되는것이기 때문에, 색칠할 때, 1씩 증가시키는 형식으로 코드를 작성했다.
728x90
'Study > Baekjoon' 카테고리의 다른 글
[백준/C++] 2501 약수 구하기 (0) | 2024.02.19 |
---|---|
[백준/C++] 5086 배수와 약수 (0) | 2024.02.19 |
[백준/C++] 10798 세로읽기 (0) | 2024.02.19 |
[백준/C++] 2566 최댓값 (0) | 2024.02.19 |
[백준/C++] 10156 과자 (0) | 2024.02.18 |