문제) 백준 - 구현 - 단어 나누기
https://www.acmicpc.net/problem/1251
1251번: 단어 나누기
알파벳 소문자로 이루어진 단어를 가지고 아래와 같은 과정을 해 보려고 한다. 먼저 단어에서 임의의 두 부분을 골라서 단어를 쪼갠다. 즉, 주어진 단어를 세 개의 더 작은 단어로 나누는 것이다
www.acmicpc.net
Python 소스코드)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = input() | |
li = [] | |
for i in range(len(s) - 2): | |
for j in range(i + 1, len(s) - 1): | |
for k in range(j + 1, len(s)): | |
temp = s[:j][::-1] + s[j:k][::-1] + s[k:][::-1] | |
li.append(temp) | |
li.sort() | |
print(li[0]) |
Full Code)
GitHub - Chocochip101/BOJ_Solution: BOJ Solutions
BOJ Solutions. Contribute to Chocochip101/BOJ_Solution development by creating an account on GitHub.
github.com
반응형
'PS(Problem Solving) > 백준_BOJ' 카테고리의 다른 글
[백준] 9024번 - 두 수의 합 (C++) 문제 및 풀이 (0) | 2022.03.07 |
---|---|
[백준] 21940번 - 가운데에서 만나기 (C++) 문제 및 풀이 (0) | 2022.03.06 |
[백준] 14430번 - 자원 캐기 (C++) 문제 및 풀이 (0) | 2022.03.04 |
[백준] 9996번 - 한국이 그리울 땐 서버에 접속하지 (Python) 문제 및 풀이 (0) | 2022.03.03 |
[백준] 22943번 - 수 (Python) 문제 및 풀이 (0) | 2022.03.02 |
댓글