Post

๐Ÿข ZOAC

1. ๋ฌธ์ œ ๋งํฌ

16719๋ฒˆ: ZOAC


2. ์ฝ”๋“œ

Python3 31256KB 44ms

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
[16719] ZOAC

๐Ÿ’› ๋ฌธ์ œ
2018๋…„ 12์›”, ์ฒ˜์Œ ์‹œ์ž‘ํ•˜๊ฒŒ ๋œ ZOAC์˜ ์˜คํ”„๋‹์„ ๋งก์€ ์„ฑ์šฐ๋Š” ๋ˆ„๊ตฌ๋ณด๋‹ค ํ™”๋ คํ•˜๊ฒŒ ZOAC๋ฅผ ์•Œ๋ฆฌ๋ ค ํ•œ๋‹ค.
์•ž ๊ธ€์ž๋ถ€ํ„ฐ ํ•˜๋‚˜์”ฉ ๋ณด์—ฌ์ฃผ๋Š” ๋ฐฉ์‹์€ ๋„ˆ๋ฌด ์‹์ƒํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•œ ์„ฑ์šฐ๋Š” ๋ฌธ์ž์—ด์„ ๋ณด์—ฌ์ฃผ๋Š” ์ƒˆ๋กœ์šด ๊ทœ์น™์„ ๊ณ ์•ˆํ•ด๋ƒˆ๋‹ค!
๊ทœ์น™์€ ์ด๋Ÿฌํ•˜๋‹ค. ์•„์ง ๋ณด์—ฌ์ฃผ์ง€ ์•Š์€ ๋ฌธ์ž ์ค‘ ์ถ”๊ฐ€ํ–ˆ์„ ๋•Œ์˜ ๋ฌธ์ž์—ด์ด ์‚ฌ์ „ ์ˆœ์œผ๋กœ ๊ฐ€์žฅ ์•ž์— ์˜ค๋„๋ก ํ•˜๋Š” ๋ฌธ์ž๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๊ฒƒ์ด๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด ZOAC๋ฅผ ๋ณด์—ฌ์ฃผ๊ณ  ์‹ถ๋‹ค๋ฉด, A โ†’ AC โ†’ OAC โ†’ ZOAC ์ˆœ์œผ๋กœ ๋ณด์—ฌ์ฃผ๋ฉด ๋œ๋‹ค.
๋ฐ”์œ ์„ฑ์šฐ๋ฅผ ์œ„ํ•˜์—ฌ ์ด ๊ทœ์น™๋Œ€๋กœ ์ถœ๋ ฅํ•ด์ฃผ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

๐Ÿ’š ์ž…๋ ฅ
์ฒซ ๋ฒˆ์งธ ์ค„์— ์•ŒํŒŒ๋ฒณ ๋Œ€๋ฌธ์ž๋กœ ๊ตฌ์„ฑ๋œ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์ง„๋‹ค. ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋Š” ์ตœ๋Œ€ 100์ž์ด๋‹ค.

๐Ÿ’™ ์ถœ๋ ฅ
๊ทœ์น™์— ๋งž๊ฒŒ ์ˆœ์„œ๋Œ€๋กœ ๋ฌธ์ž์—ด์„ ์ถœ๋ ฅํ•œ๋‹ค.
"""

import sys
string = list(input())
temp = [[0]*2 for _ in range(len(string))]

# ZOAC : [(90, 0), (79, 1), (65, 2), (67, 3)]
# for i in range(len(string)):
#     temp[i] = ord(string[i]), i

# temp.sort(key=lambda x: (x[0], -x[1]))
# print(temp)  # => [(65, 2), (67, 3), (79, 1), (90, 0)]

result = [''] * len(string)


def func(arr, start):
    if not arr:
        return
    _min = min(arr)
    idx = arr.index(_min)
    result[start+idx] = _min

    print("".join(result))
    func(arr[idx+1:], start+idx+1)
    func(arr[:idx], start)

func(string, 0)


3. ํ•ด์„ค

๋งŒ๋“  ๋ฌธ์ž์—ด์„ ์‚ฌ์ „์ˆœ์œผ๋กœ ์ถœ๋ ฅ์ธ๋ฐ, ์•ŒํŒŒ๋ฒณ ์ž‘์€ ์‚ฌ์ „์ˆœ์œผ๋กœ ์ถ”๊ฐ€๋งŒ ํ–ˆ๋‹คโ€ฆ.

๋ฌธ์ œ๋ฅผ ์ž˜๋ชป์ดํ•ดํ–ˆ๋‹ค.

๊ทธ๋ž˜์„œ ์•ž ๋’ค๋กœ ๋” ์ž‘์€ ๊ฒƒ๋“ค์ด ์žˆ๋Š”์ง€ ํ™•์ธ์„ ํ•ด์•ผํ•œ๋‹ค

This post is licensed under CC BY 4.0 by the author.