[백준] 1593 : 문자 해독 (파이썬)
·
카테고리 없음
슬라이딩 윈도우 문제https://www.acmicpc.net/problem/1593💡풀이코드 (성공 - 슬라이딩 윈도우)import syslenW, lenS = map(int, sys.stdin.readline().split())w = list(str(sys.stdin.readline().strip()))s = str(sys.stdin.readline().strip())wl = [0] * 58sl = [0] * 58answer = 0for i in w: wl[ord(i)-65] += 1def solution(): global answer length = 0 for i in range(lenS): sl[ord(s[i])-65] += 1 length += ..
[프로그래머스] Level2 : 주차 요금 계산 (파이썬, C++)
·
Algorithm/Dictionary
구현, 해시 문제https://school.programmers.co.kr/learn/courses/30/lessons/92341 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr💡풀이코드 (성공 - Python)import heapqimport mathdef solution(fees, records): answer = [] # 기본시간(분), 기본요금(원), 단위시간(분), 단위요금(원) bTime = fees[0] bFee = fees[1] pTime = fees[2] pFee = fees[3] dic = {} for str in reco..
[프로그래머스] Level3 : 섬 연결하기 (파이썬)
·
Algorithm/Graph
MST 문제https://school.programmers.co.kr/learn/courses/30/lessons/42861 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr💡풀이코드 (성공 - MST Kruskal)def solution(n, costs): answer = [] graph = [] ans = 0 for n1, n2, w in costs: graph.append((w, n1, n2)) parent = [0] * (n + 1) def init(): for i in range(1, n + 1): parent[i..
[프로그래머스] Level3 : 양과 늑대(파이썬)
·
카테고리 없음
백트래킹 문제https://school.programmers.co.kr/learn/courses/30/lessons/92343 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 💡 풀이코드1(Python 성공-DFS)양방향 그래프일 필요 X단방향 그래프를 통하여, 재귀호출을 구현할 수 있는 방법을 찾을 필요가 존재합니다.바로 그 답은, 다음 차례에 이동 가능한 정점을 따로 담아서 재귀호출을 하는 것입니다.def dfs(idx, sheep, wolf, possible): global g_info, answer, graph print(idx, possible, sheep) if g_info[i..
[백준] 1987 : 알파벳 (파이썬)
·
Algorithm/Back Tracking
그리디, 백트래킹 문제https://www.acmicpc.net/problem/1987접근 방식 백트래킹💡 풀이코드 (Pypy3 성공 - DFS)import sys r, c = map(int, sys.stdin.readline().split())graph = []dy = [1, 0, -1, 0]dx = [0, 1, 0, -1]visited= [[False] * c for _ in range(r)]ans = 0alpha = set()# print(visited)for _ in range(r): l = list(map(str, sys.stdin.readline().strip())) # 문자열 하나하나씩 저장 alpha.update(l) # ['H', 'M', 'C', 'H', 'H']를 한번에 ..
[프로그래머스] Lv.2 충돌위험 방지 (파이썬)
·
Algorithm/Simulation
구현, 시뮬레이션 문제https://school.programmers.co.kr/learn/courses/30/lessons/340211 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr문제 설명 routes = []에 몇번 point가 몇번 point로 이동할 것인지의 정보가 주어진다.우리는 routes의 정보를 가지고, point -> point로 이동할 때 최단 경로만을 사용해서 이동하고 싶다.이때, r좌표의 이동을 c좌표의 이동보다 우선시한다.최종적으로는 routes에 있는 point -> point로 동시에 이동시킬 때, 몇 번 충돌하는지 알고 싶다.접근 방식초기BFS를 통해 각각의 point에서..
_은선_
esssun.log