본문 바로가기

정올문제소스코드

1671 : 색종이(중)

import java.util.Scanner;
 
public class Main {
     
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
         
        int paperCnt;
        int x, y;
        int cnt = 0;
        int paper[][] = new int [101][101];
        int i, j;
         
        paperCnt = scan.nextInt();
        while (paperCnt-- > 0) {
            y = scan.nextInt();
            x = scan.nextInt();
            
            for (i = y; i < y + 10; i++) {
                for (j = x; j < x + 10; j++) {
                    paper[i][j] = 1;
                }
            }
             
        }
         
        for (i = 0; i < 101; i++) {
            for (j = 0; j < 101; j++) {
                if (paper[i][j] == 1) {
                    if (paper[i + 1][j] == 0) {
                        cnt++;
                    }
                    if (paper[i - 1][j] == 0) {
                        cnt++;
                    }
                    if (paper[i][j + 1] == 0) {
                        cnt++;
                    }
                    if (paper[i][j - 1] == 0) {
                        cnt++;
                    }
                }
                 
                 
                     
            }
        }
             
        System.out.println(cnt);
        
    }
}

http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=944&sca=2060

'정올문제소스코드' 카테고리의 다른 글

1997 : 떡 먹는 호랑이  (0) 2021.10.29
1311 : 카드게임  (0) 2021.10.29
1438 : 색종이(초)  (0) 2021.10.29
3699 : 변장  (0) 2021.10.08
1516 : 단어 세기  (0) 2021.10.08