본문 바로가기

전체 글442

숨바꼭질 4 def BOJ13913(): n, k = map(int, input().split()) graph = [1e9] * 100001 queue = [] graph[n] = 0 queue.append([n, 0]) dict = {n: n} while queue: current_node, current_time = queue.pop(0) next_time = current_time + 1 next_node = current_node - 1 if 0 2022. 1. 6.
숨바꼭질 [백준 1697] - python def BOJ1679(): n, k = map(int, input().split()) graph = [1e9] * 100001 queue = [] graph[n] = 0 queue.append([n, 0]) while queue: current_node, current_time = queue.pop(0) next_node = current_node - 1 if 0 2022. 1. 5.
케빈 베이컨의 6단계 법칙 def BOJ1389() : n, m = map(int, input().split()) temp = [[1e9] * n for _ in range(n)] for _ in range(m) : start, end = map(int, input().split()) temp[start-1][end-1] = 1 temp[end-1][start-1] = 1 for mid in range(n) : for start in range(n) : for end in range(n) : if mid != end and temp[start][mid] and temp[mid][end]: temp[start][end] = min(temp[start][end], temp[start][mid] + temp[mid][end]) resu.. 2022. 1. 4.
서버 기본 세팅 sudo apt-get install curl curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt-get install -y nodejs sudo apit-get install build-essential sudo apt-get install build-essential sudo npm install -g pm2 sudo npm install -g yarn sudo npm install -g n 2022. 1. 3.
가장 큰 증가 부분 수열[백준 11055] - python import sys input = sys.stdin.readline def BOJ11055() : N = int(input()) array = list(map(int, input().split())) memo = list(array) for index in range(1, len(array)) : max_point = 0 for j in range(index) : if array[j] < array[index] and max_point < memo[j] + array[index] : max_point = memo[j] + array[index] memo[index] = max(memo[index], max_point) print(max(memo)) BOJ11055() 접근 방법 0. 다이나믹 프로그래밍 .. 2022. 1. 2.
LCS [백준 9251] - python def BOJ9251() : first = input() second = input() array = [[0] * (len(second) + 1) for _ in range(len(first) + 1)] for i in range(1, len(first) + 1) : for j in range(1, len(second) + 1) : if first[i-1] == second[j-1] : array[i][j] = array[i-1][j-1] + 1 else : array[i][j] = max(array[i-1][j], array[i][j-1]) print(array[len(first)][len(second)]) BOJ9251() 접근방법 : 1. 이차원 배열로 접근 2. 비교하는 문자열이 같다면 대각선에서.. 2022. 1. 1.