Post

๐Ÿฃ ZOAC

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

16719๋ฒˆ: ZOAC



2. ์ฝ”๋“œ

Python92ms31256KB
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
c = input()

t = ''
visited = [False] * len(c) # ๋ฌธ์ž์—ด ๋ฐฉ๋ฌธ ์ฒ˜๋ฆฌ

while len(t) < len(c):
    max_score = 'Z' * 100 # ์ตœ๋Œ€ 100๊ฐœ๊นŒ์ง€
    max_target = 0
    now, t = '', ''

    for i in range(len(c)):
        if visited[i]:
            now += c[i]
            continue

				# ๋งŒ์•ฝ ๋ฏธ๋ฐฉ๋ฌธ ์•ŒํŒŒ๋ฒณ์ด๋ฉด ํ•ด๋‹น ์•ŒํŒŒ๋ฒณ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ตœ์„ ์ธ์ง€ ํŒ๋‹จ
				# max_score ๊ณ„์‚ฐ
        if not visited[i]:
            tmp = now + c[i]
            for j in range(i + 1, len(c)):
                if visited[j]:
                    tmp += c[j]
            if tmp < max_score: # ์•ŒํŒŒ๋ฒณ ์ˆœ์„œ ๊ณ„์‚ฐ
                max_score = tmp
                max_target = i

    visited[max_target] = True
    for i in range(len(c)):
        if visited[i]:
            t += c[i]
    print(t)



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