[๋ฐฑ์ค€ ๐Ÿฅˆ5] 25757๋ฒˆ ์ž„์Šค์™€ ํ•จ๊ป˜ํ•˜๋Š” ๋ฏธ๋‹ˆ๊ฒŒ์ž„ (Python/ํŒŒ์ด์ฌ)

mingssoยท2023๋…„ 3์›” 19์ผ
0

Algorithm

๋ชฉ๋ก ๋ณด๊ธฐ
25/35

1๏ธโƒฃ ๋ฌธ์ œ

https://www.acmicpc.net/problem/25757



2๏ธโƒฃ ์ฝ”๋“œ

import sys

n, k = sys.stdin.readline().split()
people = set()    # set์„ ์ด์šฉํ•ด ์ฃผ์–ด์ง„ ์‚ฌ๋žŒ๋“ค์„ ์ค‘๋ณต ์ œ๊ฑฐ
for _ in range(int(n)):
    people.add(sys.stdin.readline().rstrip())

p = len(people)

if k == 'Y':   # ์œท๋†€์ด
    print(p)
elif k == 'F':   # ๊ฐ™์€ ๊ทธ๋ฆผ ์ฐพ๊ธฐ
    print(p//2)
else:   # ์›์นด๋“œ
    print(p//3)



3๏ธโƒฃ ํ’€์ด

๊ฐ„๋‹จํ•œ ์ˆ˜ํ•™ ๋ฌธ์ œ
๋งŒ์•ฝ ์œท๋†€์ด ๊ฒŒ์ž„์„ ํ•˜๋ ค๊ณ  ํ•œ๋‹ค๋ฉด ์ž„์Šค๋ฅผ ์ œ์™ธํ•œ ํ•œ์‚ฌ๋žŒ๋งŒ ๋” ๊ตฌํ•˜๋ฉด ๋œ๋‹ค
๊ณ ๋กœ ๊ฐ™์ด ํ”Œ๋ ˆ์ดํ•˜๊ณ ์ž ํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์˜ ์ธ์›์ˆ˜์™€ ๊ฒฝ์šฐ์˜ ์ˆ˜๊ฐ€ ๊ฐ™์Œ!
โ€‹
๊ฐ™์€ ๊ทธ๋ฆผ ์ฐพ๊ธฐ ๊ฒŒ์ž„์˜ ๊ฒฝ์šฐ ์ž„์Šค๋ฅผ ์ œ์™ธํ•œ ๋‘ ์‚ฌ๋žŒ์„ ๋” ๊ตฌํ•ด์•ผ ํ•œ๋‹ค
๊ฐ™์ด ๊ฒŒ์ž„์„ ํ•˜๊ณ  ์‹ถ์–ดํ•˜๋Š” ์‚ฌ๋žŒ A B C ๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•˜๋ฉด, ์ž„์Šค๋Š” AB๋ž‘ ํ•˜๋“ ์ง€ BC๋ž‘ ํ•˜๋“ ์ง€ AC๋ž‘ ํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ
๊ฒฐ๋ก ์ ์œผ๋กœ ๋ˆ„๊ตฌ๋ž‘ ํ•˜๋“ ์ง€ ํ•œ๋ฒˆ๋งŒ ๊ฒŒ์ž„์„ ํ•  ์ˆ˜ ์žˆ๋‹ค = p//2
โ€‹

profile
๐Ÿฅ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ’ฐ

0๊ฐœ์˜ ๋Œ“๊ธ€