Skip to content

250609 dahlbong#83

Open
dahlbong wants to merge 2 commits intomainfrom
250609_dahlbong
Open

250609 dahlbong#83
dahlbong wants to merge 2 commits intomainfrom
250609_dahlbong

Conversation

@dahlbong
Copy link
Copy Markdown
Contributor

@dahlbong dahlbong commented Jun 9, 2025

16918 봄버맨 - solved

알고리즘

  • 구현

접근방식

  • 시간에 따른 상태 변화를 단계별로 시뮬레이션
    • 1초: 아무것도 하지 않음
    • 2초: 빈 칸에 폭탄 설치
    • 3초: 3초 전에 설치된 폭탄들이 폭발
  • 이후 2초와 3초를 반복하며 N초까지 진행
  • 각 폭탄의 설치 시간을 기록하여 폭발 시점 관리

시공간 복잡도

  • 시간복잡도: O(N × R × C) // N초 동안 R×C 격자를 처리
  • 공간복잡도: O(R × C) // 격자 상태를 저장하는 2차원 배열

2138 전구와 스위치 - solved

알고리즘

  • 그리디

접근방식

  • 스위치를 누르면 해당 위치와 인접한 전구들의 상태가 바뀌는 특성을 이용
    • 첫 번째 스위치를 누르는 경우와 누르지 않는 경우로 나누어 탐색
    • 왼쪽부터 순서대로 처리하며, 이전 전구가 목표 상태와 다르면 현재 스위치를 누름
  • 두 가지 경우 중 최솟값을 선택하여 답 도출

시공간 복잡도

  • 시간복잡도: O(N) // 리스트 두 번 순회 (첫 번째 스위치를 누르는 경우/안 누르는 경우)
  • 공간복잡도: O(N) // 전구 상태를 저장하는 배열

@dahlbong dahlbong requested a review from yujin0124 June 9, 2025 13:44
@dahlbong dahlbong added the AllSolved! 올솔 label Jun 9, 2025
if 0 <= nx < R and 0 <= ny < C:
new_board[nx][ny] = '.'

return new_board
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

새로운 배열에 결과를 저장하는건 배열을 전역변수로 선언하는 것을 피하기위해서인가요?

asis = list(input().rstrip())
tobe = list(input().rstrip())

def button(x, bulbs):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

이 양 옆 버튼까지 처리하는 부분이 가독성면에서 반복문을 매번 돌리기도 신경쓰이고 같은 행동을 3번 하는 것도 신경쓰였는데 저도 다현님처럼 짧더라도 함수로 뺄 걸 그랬네요

@@ -0,0 +1,40 @@
R, C, N = map(int, input().split())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

이 문제 N=1 / N이 짝수 / N을 4로 나눴을 때 나머지가 3 / N을 4로 나눴을 때 나머지가 1(1제외) 의 결과가 매번 똑같이 반복되어서 그 방식으로도 풀어보시면 시간복잡도 측면에서 많이 개선됩니다!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants