practivceAlgorithm/swexpertacademy 84

[SWEA][Python] 1240 단순2진암호코드

암호를 찾으면 7자리씩 decoding하고 배열에 저장해 유효성 판단하고 값을 반환합니다. 따로 알고리즘이 필요한 문제는 아닙니다. for test in range(1, int(input()) + 1): N, M = map(int, input().split()) nums = {'0001101': 0, '0011001': 1, '0010011': 2, '0111101': 3, '0100011': 4, '0110001': 5, '0101111': 6, '0111011': 7, '0110111': 8, '0001011': 9} bits = [] for _ in range(N): a = input() idx = 0 if bits: continue while idx < M - 7: idx += 1 if a[idx..

[SWEA][Python] 5203 베이비진 게임

각 경우의 수를 check 해주면 된다. def check(player, num): if player[num] == 3: return True if num > 1 and player[num - 1] and player[num - 2]: return True if num < 9 and player[num + 1] and player[num + 2]: return True if num and not num==9 and player[num + 1] and player[num - 1]: return True return False for test in range(1, int(input()) + 1): nums = list(map(int, input().split())) a = {i: 0 for i in rang..

[SWEA][Python] 5201 컨테이너 운반

요새 비슷한 문제 너무 많이 풀었다. 매칭문제. 투포인터로 매칭 for test in range(1, int(input()) + 1): N, M = map(int, input().split()) w = list(map(int, input().split())) t = list(map(int, input().split())) t.sort(reverse=True) w.sort(reverse=True) answer = 0 left = 0 for truck in t: while left < N and truck < w[left]: left += 1 if left == N: break answer += w[left] left += 1 print(f'#{test} {answer}')

[SWEA][Python] 5189 전자카트

마찬가지로 백트래킹 문제. def dfs(depth, cur_node, total): global min_sum if depth == N-1: min_sum = min(min_sum, total + matrix[cur_node][0]) return if total > min_sum: return for next_node in range(N): if not col_check[next_node]: col_check[next_node] = True dfs(depth + 1, next_node, total + matrix[cur_node][next_node]) col_check[next_node] = False for test in range(1, int(input()) + 1): N = int(input())..