[Baekjoon] 2563 색종이


문제

문제 전문을 여기에 입력.

입력

입력 조건을 여기에 입력.

테스트 케이스 및 예시 결과

문제에서 주어지는 테스트 케이스와 예상 결과를 여기에 입력

해답

import java.util.*;
import java.io.*;

public class Main {

    public static void solution() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(br.readLine());
        
        int[][] paper = new int[100][100];
        int totalArea = 0;

        for (int i = 0; i < n; i++) {
            StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            int x = Integer.parseInt(st.nextToken());
            int y = Integer.parseInt(st.nextToken());

            for (int j = x; j < x + 10; j++) {
                for (int k = y; k < y + 10; k++) {
                    paper[j][k] = 1;
                }
            }
        }

        for (int i = 0; i < 100; i++) {
            for (int j = 0; j < 100; j++) {
                if (paper[i][j] == 1) {
                    totalArea++;
                }
            }
        }

        bw.write(String.valueOf(totalArea));
        bw.flush();
        bw.close();
        br.close();
    }

    public static void main(String[] args) throws IOException {
        solution();
    }
}

풀이

문제 분할

문제를 분할-정복하기 위해 분할한 내용을 여기에 기술

해설

문제에 대한 알고리즘, 자료구조. 풀이에 대한 내용을 여기에 기술