[백준] 17090 : 미로 탈출하기 (파이썬)
·
카테고리 없음
Memorization 문제https://www.acmicpc.net/problem/17090 17090번: 미로 탈출하기크기가 N×M인 미로가 있고, 미로는 크기가 1×1인 칸으로 나누어져 있다. 미로의 각 칸에는 문자가 하나 적혀있는데, 적혀있는 문자에 따라서 다른 칸으로 이동할 수 있다. 어떤 칸(r, c)에 적힌 문www.acmicpc.net 💡 풀이코드 (성공)import syssys.setrecursionlimit(10**6)r, c = map(int, sys.stdin.readline().split())graph = [list(sys.stdin.readline().strip()) for _ in range(r)]# -1: 아직 방문 안 함# 0: 탈출 불가# 1: 탈출 가능memo = [..
[백준] 3055 : 탈출 (파이썬)
·
Algorithm/Graph
BFS 문제https://www.acmicpc.net/problem/3055💡풀이코드 (성공 - BFS)'''.: 비어있는곳 (물 O, 고슴도치 O)*: 물 (물 O, 고슴도치 X)X: 돌 (물 X, 고슴도치 X)D: 비버의 굴 (물 X, 고슴도치 O)S: 고슴도치 위치 (물 O, 고슴도치 O)'''# 9:30 ~import sys from collections import dequer, c = map(int, sys.stdin.readline().split())visited = [[False] * c for _ in range(r)]visitedW = [[False] * c for _ in range(r)]graph = []S = None # 2) 좌표 사용 시 튜플 처음 선언D = Nonewater..
[백준] 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..
_은선_
'분류 전체보기' 카테고리의 글 목록