๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm/๋ฐฑ์ค€(BOJ)

[ ํŒŒ์ด์ฌ(python) ] ๋ฐฑ์ค€ 2563 - ์ƒ‰์ข…์ด

by YWTechIT 2021. 6. 23.
728x90

๐Ÿ“ ๋ฐฑ์ค€ 2563 - ์ƒ‰์ข…์ด

๋ฐฑ์ค€ 2563 - ์ƒ‰์ข…์ด


โšก๏ธ ๋‚˜์˜ ํ’€์ด

์ƒ‰์ข…์ด๊ฐ€ ๋ถ™์€ ๊ฒ€์€ ์˜์—ญ์˜ ๋„“์ด๋ฅผ ๊ตฌํ•˜๋Š” ๋ฌธ์ œ๋ผ์„œ ์ฒ˜์Œ์— (100 * n) - ์ƒ‰์ข…์ด๋ผ๋ฆฌ ๊ฒน์น˜๋Š” ๋„“์ด๋กœ ๊ตฌํ•˜๋ฉด ๋  ์ค„ ์•Œ์•˜๋Š”๋ฐ ์ƒ‰์ข…์ด๊ฐ€ ๊ฒน์น˜๋Š” ๊ฒฝ์šฐ + ๊ฒน์น˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ๋“ฑ๋“ฑ.. ๊ฒฝ์šฐ์˜ ์ˆ˜๊ฐ€ ๋งŽ์•„ ์ด ๋ฐฉ๋ฒ•์€ ํž˜๋“ค๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค. 2์ฐจ์› ๋ฐฐ์—ด์„ ์„ ์–ธํ•œ ๋‹ค์Œ ๊ฐ€๋กœ, ์„ธ๋กœ์˜ ๊ธธ์ด๋ฅผ 1๋กœ ์ดˆ๊ธฐํ™”ํ•ด์ฃผ๋Š” ๋ฐฉ๋ฒ•์„ ๋ดค๋Š”๋ฐ, ์ด๋Ÿฐ ๋ฐฉ๋ฒ•๋„ ์žˆ๊ตฌ๋‚˜ ํ•˜๋ฉฐ ๊ฐํƒ„ํ–ˆ๋‹ค.

 

๊ทธ๋ž˜์„œ white_board[i][j] += 1๋กœ ์„ ์–ธํ•œ ๋‹ค์Œ 300 - cnt >= 2๋กœ ๊ตฌํ–ˆ๋”๋‹ˆ ์˜ค๋‹ตํŒ์ •์ด ๋‚˜์™”๋‹ค. ๊ฒฐ๋ก ์ ์œผ๋กœ 1์”ฉ ๋ˆ„์ ํ•  ํ•„์š” ์—†์ด ์ „์ฒด ์‚ฌ๊ฐํ˜•์ด ๊ทธ๋ ค์ง„ ๊ฐ’(1)๋งŒ ์ถœ๋ ฅํ•˜๋ฉด ๋์—ˆ๋‹ค.

 

n = int(input())
white_board = [[0] * 100 for _ in range(100)]

for _ in range(n):
    a, b = map(int, input().split())

    for i in range(b, b + 10):
        for j in range(a, a + 10):
            white_board[i][j] = 1

cnt = 0
for i in range(100):
    for j in range(100):
        if white_board[i][j]:
            cnt += 1

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

๋Œ“๊ธ€