๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿƒ algorithm/boj

BOJ 2563 - ์ƒ‰์ข…์ด

by HandHand 2021. 3. 18.

๋ฌธ์ œ

๋ฐฑ์ค€ ์˜จ๋ผ์ธ ์ €์ง€ - 2563๋ฒˆ

ํ’€์ด ๊ณผ์ •

์ƒ‰์ข…์ด์˜ ์ขŒํ‘œ๊ฐ’์„ ์ด์šฉํ•ด์„œ ๊ฒน์นœ ๋ถ€๋ถ„์˜ ๋„“์ด๋ฅผ ๊ตฌํ•˜๋Š” ๊ตฌํ˜„ ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.
์ƒ‰์ข…์ด๋ฅผ ๋†“์„ ๋„ํ™”์ง€๋ฅผ board ๋กœ ์ •์˜ํ•˜๊ณ  ๊ฐ๊ฐ์˜ ์ƒ‰์ข…์ด๋กœ ์ธํ•ด ๋ฎ์ธ ๋ถ€๋ถ„์„ 1๋กœ ํ‘œ๊ธฐํ•˜๋ฉด
๊ฒน์น˜๋Š” ๋ถ€๋ถ„์„ ํฌํ•จํ•œ ๋„“์ด๋ฅผ ์‰ฝ๊ฒŒ ๊ตฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ฝ”๋“œ


import sys


N = int(input())
papers = []
for _ in range(N):
    papers.append(list(map(int, sys.stdin.readline().split())))


def solution():
    board = [[0]*100 for _ in range(100)]

    # ์ƒ‰์ข…์ด ์ฑ„์šฐ๊ธฐ
    for r, c in papers:
        for row in range(r, r+10):
            for col in range(c, c+10):
                board[row][col] = 1

    # ๋„“์ด ๊ณ„์‚ฐํ•˜๊ธฐ
    ans = 0
    for r in range(100):
        for c in range(100):
            if board[r][c]:
                ans += 1

    return ans


print(solution())
๋ฐ˜์‘ํ˜•

'๐Ÿƒ algorithm > boj' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

BOJ 6593 - ์ƒ๋ฒ” ๋นŒ๋”ฉ  (0) 2021.03.18
BOJ 16397 - ํƒˆ์ถœ  (0) 2021.03.18
BOJ 1963 - ์†Œ์ˆ˜ ๊ฒฝ๋กœ  (0) 2021.03.18
BOJ 4195 - ์นœ๊ตฌ ๋„คํŠธ์›Œํฌ  (0) 2021.03.18
BOJ 17626 - Four Squares  (0) 2021.03.18

๐Ÿ’ฌ ๋Œ“๊ธ€