Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-08-18] wooyeol #114 #135

Merged
merged 1 commit into from
Aug 18, 2023
Merged

[2023-08-18] wooyeol #114 #135

merged 1 commit into from
Aug 18, 2023

Conversation

Woo-Yeol
Copy link
Member

PR Summary

종이의 개수
https://www.acmicpc.net/problem/1780

풀이시간
08:30 ~ 09:30 + 13:30~14:44 (2시간 14분)
N(1 <= N <= 37, N은 3k 꼴)

접근법
무슨 알고리즘으로 풀이 할 수 있을까? 재귀 / 분할 정복

문제에는 두 가지 조건이 주어진다. 첫 번째는 9개의 값이 같은 값이라면 그 종이는 하나
9개의 값이 다른 경우 그 종이는 각각 하나의 종이씩이다.

그렇기에 범위 내의 데이터가 모두 같을 경우와 같지 않을 경우를 검사하고 같지 않다면
9개로 나눠서 다시 연산 진행 3N 으로 주어지기에 3(N-1)의 경우 다시 검사하여
9개로 나눠진 값이 각각 하나씩만 반환할 때까지 분할해서 정복한다.

풀이 참조 : https://velog.io/@yje876/python백준분할정복-1780-종이의-개수

@Woo-Yeol Woo-Yeol added the BOJ label Aug 18, 2023
@Woo-Yeol Woo-Yeol requested a review from limstonestone August 18, 2023 05:46
@Woo-Yeol Woo-Yeol self-assigned this Aug 18, 2023
@Woo-Yeol Woo-Yeol linked an issue Aug 18, 2023 that may be closed by this pull request
Copy link
Contributor

@zsmalla zsmalla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전반적으로 직관적으로 코드를 구성하셔서 개인적으로 이해하기 정말 편했습니다. 고생하셨습니다~


def recursive(n: int, row: int, col: int):
# 조건 1: 하나의 값으로만 이루어져 있을 경우
if not is_same_value(n, row, col):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 함수 덕에 훨씬 직관적이네요!

n_trisection = n // 3

# 첫번째 행
recursive(n_trisection, row, col)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 친구들도 마찬가지로 직관적이어서 좋습니다! 다만 보는 관점에 따라서 해당 9개의 경우의 수를 반복문으로 작성하는 경우를 좋게 보는 분들도 계실 것 같네요. 시간 날 때 한 번 개선해보시면 좋을 것 같습니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지수님 말씀처럼 저는 이 부분을 반복문으로 구현해서 풀었는데 반복문으로 써보시면 코드가 좀 더 간결해보일 수 있을 것 같아요!

n_trisection = n // 3

# 첫번째 행
recursive(n_trisection, row, col)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지수님 말씀처럼 저는 이 부분을 반복문으로 구현해서 풀었는데 반복문으로 써보시면 코드가 좀 더 간결해보일 수 있을 것 같아요!

@ksumini ksumini removed the request for review from limstonestone August 18, 2023 11:11
@ksumini ksumini merged commit a8ce8a2 into main Aug 18, 2023
@ksumini ksumini deleted the wooyeol-#114 branch August 18, 2023 11:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BOJ] 종이의 개수
3 participants