분류 전체보기 720

[백준][Python] 10163 색종이

색종이 덧칠하고 순회하며 갯수 세줬습니다. import sys input = sys.stdin.readline N = int(input()) matrix = [[0]*1001 for _ in range(1001)] for k in range(1,N+1): x,y,w,h = map(int, input().split()) for i in range(x,x+w): for j in range(y,y+h): matrix[i][j] = k cnt_color = [0] * (N+1) for i in range(1001): for j in range(1001): if matrix[i][j]: cnt_color[matrix[i][j]] += 1 for i in range(1,N+1): print(cnt_color[i])

[백준][Python] 10158 개미

좌표평면에서 기준선 0, w,h 축을 기준으로 범위 안에 들어올때까지 대칭시키는 방법. import sys input = sys.stdin.readline w, h = map(int, input().split()) p, q = map(int, input().split()) t = int(input()) init_x = p + t init_y = q + t if not (init_x//w)&1: x = (-2*w*((init_x//w)//2) + init_x) else: x = 2*w - (-2*w*((init_x//w)//2) + init_x) if not (init_y//h)&1: y = (-2*h*((init_y//h)//2) + init_y) else: y = 2*h - (-2*h*((init_y/..

[백준][Python] 2578 빙고

call될때마다 0으로 바꾸는 방식 5개 0이면 빙고 1줄 import sys input = sys.stdin.readline def check(x,y): global cnt if not row_check[x] and not sum(bingo[x]): row_check[x] = True cnt += 1 if not col_check[y]: for i in range(5): if bingo[i][y]: break else: col_check[y] = True cnt += 1 if x==y and not diagonal_check[0]: for i in range(5): if bingo[i][i]: break else: diagonal_check[0] = True cnt += 1 if x+y==4 and n..

[백준][Python] 2559 수열

정답이 음수값인 케이스를 고려못해서 한참 고생함.. max값 초기화는 늘 음의 무한대로 할것.. 0으로 햇다가 낭패봄 import sys input = sys.stdin.readline N, K = map(int, input().split()) arr = list(map(int, input().split())) left = 0 sum_arr = 0 max_sum = -float('inf') for right in range(N): sum_arr += arr[right] if right-left+1 == K: max_sum = max(max_sum,sum_arr) sum_arr -= arr[left] left += 1 print(max_sum)

[백준][Python] 2628 종이자르기

가로 세로 길이 집합 구해서 곱한 것들중에 최댓값 import sys input = sys.stdin.readline N, M = map(int, input().split()) cut_row = [0,M] cut_col = [0,N] for _ in range(int(input())): a,b = map(int,input().split()) if not a: cut_row.append(b) else: cut_col.append(b) cut_row.sort() cut_col.sort() len_row = [] len_col = [] for i in range(1,len(cut_row)): len_row.append(cut_row[i] - cut_row[i-1]) for i in range(1,len(cut..