삼성 Expert 1244 최대 상금
ans = 0 def dfs(count): global ans temp = int(''.join(ar)) if count == 0: ans = max(ans, temp) return for i in range(len(ar)): for j in range(i + 1, len(ar)): ar[i], ar[j] = ar[j], ar[i] temp_key = ''.join(ar) if chk.get((temp_key, count - 1), 1): chk[(temp_key, count - 1)] = 0 dfs(count - 1) ar[i], ar[j] = ar[j], ar[i] for test_case in range(1, int(input()) + 1): ans = 0 ar, n = input().split()..
2022. 6. 13.
백준 7562 나이트의 이동
from collections import deque dy = (1, 1, -1, -1, 2, 2, -2, -2) dx = (2, -2, 2, -2, 1, -1, 1, -1) N = 0 def err(ex, ey): return 0
2022. 6. 13.
백준 1743 음식물 피하기
import sys sys.setrecursionlimit(10 ** 8) dy = (0, 1, 0, -1) dx = (1, 0, -1, 0) N, M, K = map(int, input().split()) trash_map = [[False for _ in range(M)] for _ in range(N)] check_map = [[False for _ in range(M)] for _ in range(N)] answer = 0 size = 0 for _ in range(K): r, c = map(int, input().split()) trash_map[r - 1][c - 1] = True def err(ey, ex): return 0
2022. 6. 13.
백준 1987 알파벳
from collections import deque dy = (0, 1, 0, -1) dx = (1, 0, -1, 0) R, C = map(int, input().split()) move_board = [input() for _ in range(R)] check = [[set() for _ in range(C)] for _ in range(R)] ans = 0 deq = deque() deq.append((0, 0, move_board[0][0])) check[0][0].add(move_board[0][0]) def err(a, b): return 0
2022. 6. 13.
백준 2178 미로 탐색
from collections import deque dy = (0, 1, 0, -1) dx = (1, 0, -1, 0) # n -> y m -> x n, m = map(int, input().split()) labyrinth = [input() for _ in range(n)] # n개의 배열 m의 길이 check = [[False] * m for _ in range(n)] deq = deque() deq.append((0, 0, 1)) check[0][0] = True def err(a, b): return 0
2022. 6. 13.