-
Notifications
You must be signed in to change notification settings - Fork 0
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월 9일 #7
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BFS&DFS 알고리즘 코드 리뷰 완료]
p3. 전체적으로 깔끔하고 좋은 코드로 작성해주셨네요! 코멘트 남긴 부분 확인해주세요! 수고하셨습니다!
} | ||
} | ||
|
||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다음번에는 주석 작성 부탁드립니다!
void dfs(int c, vector<bool>& visited, vector<vector<int>>& com, int& cnt){ | ||
visited[c]=true; | ||
|
||
for(int i=0;i<com[c].size();i++){ | ||
int temp=com[c][i]; | ||
if(!visited[temp]){ | ||
cnt++; | ||
dfs(temp, visited, com, cnt); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
참조로 넘겨 주신 점, 깔끔한 기본 DFS 함수 좋습니다!
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 문제는 BFS로는 쓸 수 없을까요? 가능하다면 한번 작성해보세요! DFS 함수도 스택을 이용해서 구현해보셔도 도움이 많이 될 것 같습니다!
} | ||
} | ||
} | ||
cout << count << '\n'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endl을 사용하시는 편이 시간복잡도에 좋습니다!
vector<int> dir_x={-1, 1, -1, 1, 0, 0, -1, 1}; | ||
vector<int> dir_y={-1, 1, 1, -1, 1, -1, 0, 0}; | ||
int board[50][50]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다!
return (x>=0 && x<h && y>=0 && y<w); | ||
} | ||
|
||
void dfs(int x, int y, int w, int h){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 문제도 BFS로는 쓸 수 없을까요? 가능하다면 한번 작성해보세요!
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
깔끔하고 좋습니다!
인적사항
학번: 2071079
이름: 이하린
과제제출
기존 제출: 1325, 4963
추가 제출: 2615