개발일지/TIL
TIL 23-06-16 백준 색종이
sdoram
2023. 6. 16. 23:50
1. 백준 색종이
문제점
시도해 본 것들
list comprehension으로 이차원 배열 생성
False와 True가 0과 1로 구분되는 것을 활용한 총 넓이 구하기
해결 방법
from sys import stdin
white_paper = [[False for _ in range(100)] for _ in range(100)]
for _ in range(int(stdin.readline())):
black_paper = list(map(int, stdin.readline().split()))
for i in range(black_paper[0], black_paper[0] + 10):
for j in range(black_paper[1], black_paper[1] + 10):
white_paper[i][j] = True
print(sum([sum(i) for i in white_paper]))
알게 된 점
데이터의 총 크기가 정해졌다면 미리 만들어 두는 것이 효율적이다