[백준|파이썬] 16173: 점프왕 쩰리 (Small) (실버4)
문제 https://www.acmicpc.net/problem/16173 16173번: 점프왕 쩰리 (Small) 쩰리는 맨 왼쪽 위의 칸에서 출발해 (행, 열)로 나타낸 좌표계로, (1, 1) -> (2, 1) -> (3, 1) -> (3, 3)으로 이동해 게임에서 승리할 수 있다. www.acmicpc.net 🐍파이썬 더보기 메모리 초과된 코드 import sys from collections import deque n = int(sys.stdin.readline()) game = [] for _ in range(n): game.append(list(map(int, sys.stdin.readline().split()))) dy = [0, 1] dx = [1, 0] def bfs(x, y): queue..
2023. 4. 9.
[백준|파이썬] 2644: 촌수계산 (실버2)
문제 https://www.acmicpc.net/problem/2644 2644번: 촌수계산 사람들은 1, 2, 3, …, n (1 ≤ n ≤ 100)의 연속된 번호로 각각 표시된다. 입력 파일의 첫째 줄에는 전체 사람의 수 n이 주어지고, 둘째 줄에는 촌수를 계산해야 하는 서로 다른 두 사람의 번호가 주어 www.acmicpc.net 🐍파이썬 import sys n = int(sys.stdin.readline()) a, b = map(int, sys.stdin.readline().split()) m = int(sys.stdin.readline()) chon = [[] for _ in range(n+1)] for _ in range(1, m+1): c, d = map(int, sys.stdin.readl..
2023. 4. 7.
[백준|파이썬] 2178: 미로 탐색 (실버1)
문제 https://www.acmicpc.net/problem/2178 2178번: 미로 탐색 첫째 줄에 두 정수 N, M(2 ≤ N, M ≤ 100)이 주어진다. 다음 N개의 줄에는 M개의 정수로 미로가 주어진다. 각각의 수들은 붙어서 입력으로 주어진다. www.acmicpc.net 🐍파이썬 import sys from collections import deque N, M = map(int, sys.stdin.readline().split()) miro = [] for _ in range(N): miro.append(list(map(int, sys.stdin.readline().rstrip()))) #상하좌우 체크 dx = [-1, 1, 0, 0] dy = [0, 0, -1, 1] def bfs(x, ..
2023. 4. 6.