scone-lemon

[IM 대비] BOJ_2563 색종이 본문

ALGORITHM/BOJ

[IM 대비] BOJ_2563 색종이

lemon-scone 2021. 8. 29. 09:34

https://www.acmicpc.net/problem/2563

 

2563번: 색종이

가로, 세로의 크기가 각각 100인 정사각형 모양의 흰색 도화지가 있다. 이 도화지 위에 가로, 세로의 크기가 각각 10인 정사각형 모양의 검은색 색종이를 색종이의 변과 도화지의 변이 평행하도록

www.acmicpc.net

 

 

package IM_0829;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class BOJ_2563 {
	public static void main(String[] args) throws NumberFormatException, IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = null;
		
		int N = Integer.parseInt(br.readLine()); // 색종이 갯수
		int[][] map = new int[101][101];
		
		for (int n = 0; n < N; n++) {
			st = new StringTokenizer(br.readLine(), " ");
			int posx = Integer.parseInt(st.nextToken());
			int posy = Integer.parseInt(st.nextToken());
			
			for (int x = posx; x < posx + 10; x++) {
				for (int y = posy; y < posy + 10; y++) {
					map[x][y] = 1;
				}
			}
		}
		int count = 0;
		for (int i = 0; i < map.length; i++) {
			for (int j = 0; j < map[i].length; j++) {
				if (map[i][j]==1) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}