본문 바로가기

[Algorithm] 백준 BOJ 2630 색종이 만들기 python 파이썬 분할정복 실버2 Private 난이도 : ♥♥♡♡♡ 2630번: 색종이 만들기 첫째 줄에는 전체 종이의 한 변의 길이 N이 주어져 있다. N은 2, 4, 8, 16, 32, 64, 128 중 하나이다. 색종이의 각 가로줄의 정사각형칸들의 색이 윗줄부터 차례로 둘째 줄부터 마지막 줄까지 주어진다. www.acmicpc.net import sys input=sys.stdin.readline n=int(input().strip()) graph=list() for i in range(n): graph.append(list(map(int,input().strip().split(' ')))) blue=0 white=0 direction=[[0,0,1,1],[0,1,0,1]] def check(n,x,y): color=graph[x..
[Algorithm] 백준 BOJ 5904 Moo 게임 python 파이썬 분할정복 골드 5 Private 난이도 : ♥♥♥♡♡ 5904번: Moo 게임 Moo는 술자리에서 즐겁게 할 수 있는 게임이다. 이 게임은 Moo수열을 각 사람이 하나씩 순서대로 외치면 되는 게임이다. Moo 수열은 길이가 무한대이며, 다음과 같이 생겼다. m o o m o o o m o o m o o o www.acmicpc.net n=int(input()) def find_moo(partition,k,n): # [10,15,25], 2, 11 if k==0: # 가장 작은 단위일 때 if n==1: return 'm' else: return 'o' if n
[Algorithm] 백준 BOJ 1074 Z python 파이썬 분할정복 실버1 Private 난이도 : ♥♥♥♡♡ 1074번: Z 한수는 크기가 2N × 2N인 2차원 배열을 Z모양으로 탐색하려고 한다. 예를 들어, 2×2배열을 왼쪽 위칸, 오른쪽 위칸, 왼쪽 아래칸, 오른쪽 아래칸 순서대로 방문하면 Z모양이다. N > 1인 경우, 배열을 www.acmicpc.net 시간초과 코드 n,r,c=map(int,input().split(' ')) size=2**n graph=[[0 for _ in range(size)] for _ in range(size)] cnt=0 dr=[0,0,1,1] dc=[0,1,0,1] def divide(r,c,size): global cnt if size==2: for i in range(len(dr)): graph[r+dr[i]][c+dc[i]]=cnt..