https://www.acmicpc.net/problem/2563
색종이 좌표를 받으면서, 이전에 색칠된 자리가 아니면 카운트를 증가시키면 되는 간단한 문제이다.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main_bj_2563_색종이 {
public static int N,ans=0;
public static int[][] map=new int[101][101];
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
N=Integer.parseInt(br.readLine());
for(int n=0; n<N; n++) {
StringTokenizer st=new StringTokenizer(br.readLine()," ");
int y=Integer.parseInt(st.nextToken());
int x=Integer.parseInt(st.nextToken());
for(int i=x; i<x+10; i++) {
for(int j=y; j<y+10; j++) {
if(map[i][j]==0) {
map[i][j]=1;
ans++;
}
}
}
}
System.out.println(ans);
}
}
'알고리즘 문제풀이 > 백준' 카테고리의 다른 글
[백준 16987] 계란으로 계란치기(JAVA/C++) (0) | 2020.03.07 |
---|---|
[백준 14502] 연구소(JAVA/C++) (0) | 2020.03.06 |
[백준 13460] 구슬 탈출2(JAVA) (0) | 2020.03.05 |
[백준 2054] 괄호의 값(JAVA) (1) | 2020.03.04 |
[백준 2174] 로봇 시뮬레이션(JAVA) (2) | 2020.03.04 |
댓글