BOJ 15

[백준] 12100. 2048(Easy)

https://acmicpc.net/problem/12100 12100번: 2048 (Easy) 첫째 줄에 보드의 크기 N (1 ≤ N ≤ 20)이 주어진다. 둘째 줄부터 N개의 줄에는 게임판의 초기 상태가 주어진다. 0은 빈 칸을 나타내며, 이외의 값은 모두 블록을 나타낸다. 블록에 쓰여 있는 수는 2 www.acmicpc.net from copy import deepcopy def backtrack(arr, index=5, dir_arr=[]): if index == 0: global max_val tmp = findmax(arr) if max_val < tmp: max_val = tmp return else: for i in range(4): tmp_arr = deepcopy(arr) tmp_arr..

STUDY/Algorithm 2021.03.16

[백준] 10163 색종이

www.acmicpc.net/problem/10163 10163번: 색종이 평면에 색깔이 서로 다른 직사각형 모양의 색종이 N장이 하나씩 차례로 놓여진다. 이때 색종이가 비스듬하게 놓이는 경우는 없다. 즉, 모든 색종이의 변은 서로 평행하거나, 서로 수직이거나 둘 www.acmicpc.net width = height = 101 board = [[0]*width for _ in range(height)] def cover(number, s_col, s_row, wid, hei): for row in range(s_row, s_row + hei): for col in range(s_col, s_col + wid): board[row][col] = number n = int(input()) #색종이의 장수를..

STUDY/Algorithm 2021.02.22

[백준] 2615 오목

www.acmicpc.net/problem/2615 2615번: 오목 오목은 바둑판에 검은 바둑알과 흰 바둑알을 교대로 놓아서 겨루는 게임이다. 바둑판에는 19개의 가로줄과 19개의 세로줄이 그려져 있는데 가로줄은 위에서부터 아래로 1번, 2번, ... ,19번의 번호 www.acmicpc.net 더보기 badukpan = list() max_width = 19 plus_width = 5 for _ in range(plus_width): tmp = [0]*(max_width+2*plus_width) badukpan.append(tmp) for _ in range(max_width): tmp=[0] * plus_width tmp.extend(list(map(int, input().split()))) tmp..

STUDY/Algorithm 2021.02.09

[백준] 1011 Fly me to the Alpha Centauri

www.acmicpc.net/problem/1011 1011번: Fly me to the Alpha Centauri 우현이는 어린 시절, 지구 외의 다른 행성에서도 인류들이 살아갈 수 있는 미래가 오리라 믿었다. 그리고 그가 지구라는 세상에 발을 내려 놓은 지 23년이 지난 지금, 세계 최연소 ASNA 우주 비행 www.acmicpc.net import sys from math import sqrt input = sys.stdin.readline t=int(input()) for tc in range(t): x,y=map(int,input().split()) distance = y-x n=int(sqrt(distance)) if (n**2) == distance: print(2*n - 1) elif di..

STUDY/Algorithm 2021.02.07