2차원 배열에서 입력 받은 좌표의 +10 범위의 공간 크기를 구하는 문제이다.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
// 색종이 개수
int n = Integer.parseInt(input.readLine());
boolean[][] arr = new boolean[100][100];
int count = 0;
for (int i = 0; i < n; i++) {
StringTokenizer st = new StringTokenizer(input.readLine(), " ");
int column = Integer.parseInt(st.nextToken());
int row = Integer.parseInt(st.nextToken());
for (int j = row; j < row + 10; j++) {
for (int k = column; k < column + 10; k++) {
if (arr[j][k] != true) {
arr[j][k] = true;
count++;
}
}
}
}
System.out.println(count);
}
}
도화지의 100*100 배열을 boolean 자료형으로 만들어 flase로 지정해준 뒤, 반복에서 해당 배열 인덱스에 접근할 때 최초 접근이면 true로 바꾸는 로직을 통해 count 를 증가시켰고 색종이의 넓이를 구하였다.