24465 : ๋ฐ๋ท”์˜ ๊ฟˆ

24465 : ๋ฐ๋ท”์˜ ๊ฟˆ#

  • https://d2gd6pc034wcta.cloudfront.net/tier/7.svg ์‹ค๋ฒ„ 4

์‹œ๊ฐ„์ œํ•œ

๋ฉ”๋ชจ๋ฆฌ์ œํ•œ

์ •๋‹ต๋น„์œจ

1์ดˆ

512MB

56.3 %

๋ฌธ์ œ#

7์ธ์กฐ ๊ทธ๋ฃน์ธ Aloha์˜ ์ƒˆ๋กœ์šด ๋ฉค๋ฒ„๋ฅผ ๋ฝ‘๋Š” ์˜ค๋””์…˜์ด ๊ฐœ์ตœ๋˜์—ˆ๋‹ค. ํ‰์†Œ Aloha์˜ ํŒฌ์ด๋˜ ํ˜„์ˆ˜๋Š” ์˜ค๋””์…˜์— ์ง€์›ํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค.

ํ˜„์ˆ˜๋Š” 1์ฐจ ์„œ๋ฅ˜์‹ฌ์‚ฌ ๊ธฐ์ค€์ด ๊ธฐ์กด ๋ฉค๋ฒ„๋“ค๊ณผ ๋ณ„์ž๋ฆฌ๊ฐ€ ๊ฒน์น˜์ง€ ์•Š๋Š” ์‚ฌ๋žŒ์ด๋ผ๋Š” ๋‚ด๋ถ€์ •๋ณด๋ฅผ ์ž…์ˆ˜ํ–ˆ๋‹ค. ํ˜„์ˆ˜๋Š” ๊ณผ์—ฐ ์˜ค๋””์…˜์— ํ•ฉ๊ฒฉํ•  ์ˆ˜ ์žˆ์„๊นŒ?

์•„๋ž˜ ๋ณ„์ž๋ฆฌํ‘œ๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ 1์ฐจ ์„œ๋ฅ˜์‹ฌ์‚ฌ๋ฅผ ํ†ต๊ณผํ•  ์ˆ˜ ์žˆ๋Š” ์‚ฌ๋žŒ๋“ค์˜ ์ƒ์ผ์„ ์ถœ๋ ฅํ•ด๋ณด์ž.

๋ณ„์ž๋ฆฌ

๊ธฐ๊ฐ„

๋ฌผ๋ณ‘์ž๋ฆฌ

1์›” 20์ผ ~ 2์›” 18์ผ

๋ฌผ๊ณ ๊ธฐ์ž๋ฆฌ

2์›” 19์ผ ~ 3์›” 20์ผ

์–‘์ž๋ฆฌ

3์›” 21์ผ ~ 4์›” 19์ผ

ํ™ฉ์†Œ์ž๋ฆฌ

4์›” 20์ผ ~ 5์›” 20์ผ

์Œ๋‘ฅ์ด์ž๋ฆฌ

5์›” 21์ผ ~ 6์›” 21์ผ

๊ฒŒ์ž๋ฆฌ

6์›” 22์ผ ~ 7์›” 22์ผ

์‚ฌ์ž์ž๋ฆฌ

7์›” 23์ผ ~ 8์›” 22์ผ

์ฒ˜๋…€์ž๋ฆฌ

8์›” 23์ผ ~ 9์›” 22์ผ

์ฒœ์นญ์ž๋ฆฌ

9์›” 23์ผ ~ 10์›” 22์ผ

์ „๊ฐˆ์ž๋ฆฌ

10์›” 23์ผ ~ 11์›” 22์ผ

์‚ฌ์ˆ˜์ž๋ฆฌ

11์›” 23์ผ ~ 12์›” 21์ผ

์—ผ์†Œ์ž๋ฆฌ

12์›” 22์ผ ~ 1์›” 19์ผ

input#

1-7. ์ผ๊ณฑ ๋ช…์˜ aloha ๋ฉค๋ฒ„๋“ค์˜ ์ƒ์ผ์ด ํ•œ์ค„์”ฉ
8- ์˜ค๋””์…˜ ์ง€์› ์ˆ˜ n
n- ์ง€์›์ž์˜ ์ƒ์ผ์ด ํ•œ ์ค„ ์”ฉ ์ฃผ์–ด์ง.

๋ชจ๋“  ์ƒ์ผ์€ ๋‹ฌ๊ณผ ๋‚  ์ˆœ์„œ๋Œ€๋กœ ์ฃผ์–ด์ง€๋ฉด ๊ณต๋ฐฑ์œผ๋กœ ๊ตฌ๋ถ„

output#

1์ฐจ ์„œ๋ฅ˜์‹ฌ์‚ฌ ํ•ฉ๊ฒฉ์ž๋“ค์˜ ์ƒ์ผ์„ ๋น ๋ฅธ ์ˆœ์„œ๋Œ€๋กœ ํ•œ ์ค„์— ํ•˜๋‚˜์”ฉ ์ถœ๋ ฅ.
ํ•ฉ๊ฒฉ์ž๊ฐ€ ํ•œ ๋ช…๋„ ์—†๋Š” ๊ฒฝ์šฐ ALL FAILED๋ฅผ ์ถœ๋ ฅ

python#

import sys, os

problem_num = "24465"

path = os.getcwd() + f"\\txt\\{problem_num}" + ".txt"
sys.stdin = open(path, "r")
input = sys.stdin.readline
from datetime import datetime
import calendar


class Person:
    def __init__(self, month: int, day: int):
        self.year = self.find_recent_leap_year()
        self.birthday = datetime(self.year, month, day)


    def find_recent_leap_year(self):
        current_year = datetime.now().year
        for year in range(current_year, 0, -1):
            if calendar.isleap(year):
                return year
        return None

    def find_zodiac_sign(self):
        zodiac_signs = {
            "๋ฌผ๋ณ‘์ž๋ฆฌ": ((1, 20), (2, 18)),
            "๋ฌผ๊ณ ๊ธฐ์ž๋ฆฌ": ((2, 19), (3, 20)),
            "์–‘์ž๋ฆฌ": ((3, 21), (4, 19)),
            "ํ™ฉ์†Œ์ž๋ฆฌ": ((4, 20), (5, 20)),
            "์Œ๋‘ฅ์ด์ž๋ฆฌ": ((5, 21), (6, 21)),
            "๊ฒŒ์ž๋ฆฌ": ((6, 22), (7, 22)),
            "์‚ฌ์ž์ž๋ฆฌ": ((7, 23), (8, 22)),
            "์ฒ˜๋…€์ž๋ฆฌ": ((8, 23), (9, 22)),
            "์ฒœ์นญ์ž๋ฆฌ": ((9, 23), (10, 22)),
            "์ „๊ฐˆ์ž๋ฆฌ": ((10, 23), (11, 22)),
            "์‚ฌ์ˆ˜์ž๋ฆฌ": ((11, 23), (12, 21)),
            "์—ผ์†Œ์ž๋ฆฌ": ((12, 22), (1, 19)),
        }
        for sign, (start, end) in zodiac_signs.items():
            start_date = datetime(self.year, *start)
            end_date = datetime(self.year, *end)
            if start_date <= self.birthday <= end_date:
                return sign
        return "Unable to find zodiac sign"
aloha_zodiac = []
accepted = []
for _ in range(7):
    month, day = map(int, input().split())
    aloha_zodiac.append(Person(month, day).find_zodiac_sign())
n = int(input())
for _ in range(n):
    month, day = map(int, input().split())
    applier = Person(month, day)
    if applier.find_zodiac_sign() not in aloha_zodiac:
        accepted.append(applier)
if accepted:
    sorting = sorted(accepted, key=lambda x: x.birthday)
    for i in sorting:
        print(f"{int(i.birthday.month)} {int(i.birthday.day)}")
else:
    print("ALL FAILED")
2 29
9 30
10 8

ValueError#

Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError.

์•„์ฃผ ์œค๋…„๋•Œ๋ฌธ์— ๊ณ ์ƒ์„ ํ–ˆ๋‹ค. ์œค๋…„์—๋Š” 2์›”์— 29์ผ๊นŒ์ง€ ์žˆ๋Š”๋ฐ ์ด ๊ฒฝ์šฐ์—๋Š” year๊ฐ€ ์œค๋…„์ด ์•„๋‹Œ ๊ฒƒ์„ default value๋กœ ๋„ฃ์–ด๋†“์•˜์œผ๋ฉด ๊ณ„์† ValueError๊ฐ€ ๋œฌ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— calender๋กœ is_leap_year๋ฅผ ์ฐพ์•„์ค€๋‹ค์Œ์— ์ด ๋…„๋„๋ฅผ ๊ฐ€์ง€๊ณ  ์‚ฌ์šฉํ•œ๋‹ค.