[백준 20057번] 마법사 상어와 토네이도
20057번: 마법사 상어와 토네이도 마법사 상어가 토네이도를 배웠고, 오늘은 토네이도를 크기가 N×N인 격자로 나누어진 모래밭에서 연습하려고 한다. 위치 (r, c)는 격자의 r행 c열을 의미하고, A[r][c]는 (r, c)에 있는 모래의 양을 www.acmicpc.net n = int(input()) area = [list(map(int,input().split())) for _ in range(n)] dx = [0,1,0,-1] dy = [-1,0,1,0] count = 0 length = 1 direction = 0 answer = 0 x, y = n//2, n//2 def move(x,y,d): global answer total = area[x][y] five_percent = int(tot..
2023. 9. 7.
[백준 14499번] 주사위 굴리기
n, m, dice_x, dice_y, k = map(int,input().split()) area = [list(map(int,input().split())) for _ in range(n)] move_list = list(map(int,input().split())) dx = [0,0,0,-1,1] dy = [0,1,-1,0,0] # 상단, 남, 동, 서, 북, 하단 dice = [0 for _ in range(6)] for move in move_list: dice_x += dx[move] dice_y += dy[move] if dice_x = n or dice_y =m: dice_x -= dx[move] dice_y -= dy[move] con..
2023. 8. 30.
[백준 17070번] 파이프 옮기기1
17070번: 파이프 옮기기 1 유현이가 새 집으로 이사했다. 새 집의 크기는 N×N의 격자판으로 나타낼 수 있고, 1×1크기의 정사각형 칸으로 나누어져 있다. 각각의 칸은 (r, c)로 나타낼 수 있다. 여기서 r은 행의 번호, c는 열의 www.acmicpc.net n = int(input()) house = [list(map(int,input().split())) for _ in range(n)] visited = [[False]*n for _ in range(n)] dx_r, dy_r = [0,1], [1,1] # 가로일 경우 움직일 수 있는 방향 dx_c, dy_c = [1,1], [0,1] # 세로일 경우 움직일 수 있는 방향 dx_d, dy_d = [0,1,1], [1,0,1] # 대각선일 ..
2023. 8. 28.