24465 : ๋ฐ๋ท์ ๊ฟ#
์๊ฐ์ ํ |
๋ฉ๋ชจ๋ฆฌ์ ํ |
์ ๋ต๋น์จ |
---|---|---|
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๋ฅผ ์ฐพ์์ค๋ค์์ ์ด ๋
๋๋ฅผ ๊ฐ์ง๊ณ ์ฌ์ฉํ๋ค.