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

[ ํŒŒ์ด์ฌ(python) ] ๋ฐฑ์ค€ 2902 - KMP๋Š” ์™œ KMP์ผ๊นŒ?

by YWTechIT 2021. 6. 2.
728x90

๐Ÿ“ ๋ฐฑ์ค€ 2902 - KMP๋Š” ์™œ KMP์ผ๊นŒ?

๋ฐฑ์ค€ 2902 - KMP๋Š” ์™œ KMP์ผ๊นŒ?


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

์ด๋ฆ„์˜ ์ฒซ ๋ฒˆ์งธ ๊ธ€์ž, ํ•˜์ดํ”ˆ ๋’ค๋Š” ํ•ญ์ƒ ๋Œ€๋ฌธ์ž๊ธฐ ๋•Œ๋ฌธ์— ๋Œ€๋ฌธ์ž๋กœ ๋”ฐ๋กœ ๋ฐ”๊ฟ”์ฃผ๋Š” ์ฝ”๋“œ๊ฐ€ ํ•„์š” ์—†๋‹ค.

  1. ํ•˜์ดํ”ˆ์„ ๊ธฐ์ค€์œผ๋กœ ์ž…๋ ฅ์„ ๋‚˜๋ˆˆ๋‹ค.
  2. names๋ฅผ ๋ฐ˜๋ณต๋ฌธ์„ ๋Œ๋ ค i[0]๋งŒ ์ถœ๋ ฅํ•œ๋‹ค. ์‚ฌ๋žŒ์˜ ์„ฑ์˜ ์ฒซ ๊ธ€์ž๋งŒ ๋”ฐ์„œ ๋ถ€๋ฅด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
import sys
input = sys.stdin.readline

names = input().split('-')

for i in names:
    print(i[0], end='')
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€