목록12026 (1)
황소개발자
백준 12026 파이썬 python : BOJ 거리 @@황소처럼 우직하게@@ 시간초과 포비아 쉣더퍽
포비아포비아! n = int(input()) lst = input() ans = 999999999 def go(idx, cost): global ans if idx == n - 1: ans = min(ans, cost) return now = lst[idx] if now == 'B': for i in range(idx + 1, n): if lst[i] == 'O': go(i, cost + pow(i - idx, 2)) elif now == 'O': for i in range(idx + 1, n): if lst[i] == 'J': go(i, cost + pow(i - idx, 2)) elif now == 'J': for i in range(idx + 1, n): if lst[i] == 'B': go(i, ..
백준 문제 풀이
2020. 4. 24. 03:06