Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DFS&BFS] - 10월 14일 #12

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[DFS&BFS] - 10월 14일 #12

wants to merge 3 commits into from

Conversation

dasoya
Copy link
Collaborator

@dasoya dasoya commented Oct 29, 2022

내용 & 질문

1012 번은 BFS로도 풀 수 있는 문제일까요?

<기존 제출>

문제 번호 1012

Copy link

@dbswn dbswn left a comment

Choose a reason for hiding this comment

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

P3
안녕하세요 다소님 👍😄 코드도 너무 깔끔하고 주석도 작성해주셔서 리뷰 드리기 너무 좋았습니다!!! 스택으로 dfs를 구현해주셨는네요~! 이 문제는 bfs로도 구현이 가능하고 샘플코드가 제공되었으니 참고 부탁 드려요!!

간단한 코멘트 달았으니, 확인 부탁 드립니다 !수정하신 부분 있으시면 리뷰어로 불러주셔도 좋습니다! 수고 많으셨습니다.감사합니다. 🤗🤗

int new_r = r+dr[i];
int new_c = c+dc[i];

if(new_r >= 0 && new_r <n&& new_c>=0&&new_c <m&&
Copy link

Choose a reason for hiding this comment

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

P3
인덴테이션이 깊어지는 것 같은데 영역 범위 밖을 벗어나는 경우를 먼저 끊어내는게 어떨까요?! 하나라도 영역 밖으로 넘어가면 다음 케이스로 넘어가는 식으로 만들면 좋을 것 같네요!

cin >> b >> a;

matrix[a][b]= true;
stk.push({a,b}); //배추가 있는 곳을 미리 스택에 넣어둠
Copy link

Choose a reason for hiding this comment

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

처음에 배추가 있는 곳을 스택에 다 넣어주셨네요!
line 35에서 중복으로 들어가는 지점이 있기는 하지만 matrix값을 통해서 중복 방문을 잘 통제해주셔서 문제가 없어 보이네요! 처음 보는 형식이라서 굉장히 새로웠습니다!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants