728x90
λ°μν
γλͺ©μ°¨γ
0. κ°μ
1. λ¬Έμ
2. νμ΄
3. μ½λ
0. κ°μ
2μ°¨μ λ°°μ΄μ μ΄μ©νλ©΄ μ½κ² ν리μ§λ§, μ’ννλ©΄μ μ΄μ©νλ©΄ μλΉν μ΄λ €μμ§λ λ¬Έμ μ΄λ€. μ²μμ μ’ννλ©΄μΌλ‘ νλ €λ€κ° μ΄ λ¬Έμ κ° '2μ°¨μ λ°°μ΄ - λ¨κ³λ³λ‘ νμ΄λ³΄κΈ°' μ μν λ¬Έμ λΌλ κ²μ κΉ¨λ«κ³ , λ€μ 2μ°¨μ λ°°μ΄λ‘ νκΈ° μμνλ€.
1. λ¬Έμ
https://www.acmicpc.net/problem/2563
2. νμ΄
100 X 100 μ§λ¦¬ λ°°μ΄μ λ§λ ν, λ°°μ΄μ κ°μ λͺ¨λ 0 = FALSEλ‘ μ΄κΈ°ν νλ€. μ΄λ,
β = True = μμΉ λ¨ = κ²μ μμ’ μ΄ O
β‘ = False = μμΉ μλ¨ = κ²μ μμ’ μ΄ X
λΌκ³ μκ°νκ³ λ°°μ΄μ νλ λμ© μΉ ν΄κ°λ©΄μ λ¬Έμ λ₯Ό νλ©΄, μ½κ² νλ¦°λ€.
μμ 1μ κ·Έλ¦ΌμΌλ‘ λνλ΄λ©΄ λ€μκ³Ό κ°λ€.
3. μ½λ
#pragma warning(disable:4996)
#include <stdio.h>
#include <stdbool.h>
int main(int argc, char* argv[]) {
/* λνμ§ : false=0μΌλ‘ μ΄κΈ°ν */
bool canvas[100][100] = {};
/* μ
λ ₯_μμ’
μ΄ μ=N */
int N; scanf("%d", &N);
for (int i = 0; i < N; i++) {
/* μ
λ ₯_νμ΄ μ’ν */
int row, col;
scanf("%d %d", &row, &col);
/* μμΉ νκΈ° */
for (int j = col; j < col + 10; j++)
for (int k = row; k < row + 10; k++)
canvas[j][k] = true;
}
/* μΆλ ₯ */
int count = 0;
for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++)
if (canvas[i][j] == true) count++;
printf("%d", count);
/*
//debug
printf("\n");
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++)
printf("%d", canvas[i][j]);
printf("\n");
}
*/
/* λ§λ¬΄λ¦¬ */
return 0;
}
728x90
λ°μν
'γβ¨οΈα΄sγPS > λ°±μ€_μν&ꡬν' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Baekjoon/λ°±μ€][2920][C/C++] μκ³ (0) | 2023.01.21 |
---|---|
[Baekjoon/λ°±μ€][2292][C/C++] λ²μ§ (0) | 2023.01.20 |
[Baekjoon/λ°±μ€][1913][C/C++] λ¬ν½μ΄ (0) | 2023.01.19 |
[Baekjoon/λ°±μ€][2523][C/C++] λ³ μ°κΈ° - 13 (0) | 2023.01.19 |
[Baekjoon/λ°±μ€][2522][C/C++] λ³ μ°κΈ° - 12 (0) | 2023.01.19 |