-
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
[최단경로] 11월 29일 #15
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "13_\uCD5C\uB2E8\uACBD\uB85C"
[최단경로] 11월 29일 #15
Conversation
13_최단경로/1238.cpp
Outdated
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.
P3.코드리뷰완료
안녕하세요, 김연수님. 수고하셨습니다!
|
||
auto dijkstra = [&](int start) | ||
{ | ||
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; |
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.
P3. pair<int,int>를 typedef을 사용해서 짧게 사용하면 어떨까요?
int now = pq.top().second; | ||
pq.pop(); | ||
|
||
if (distance[now] < dist) continue; |
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.
이 부분은 최적화에 중요합니다. 잘하셨네요!
for (int k = 1; k <= n; ++k) | ||
{ | ||
for (int i = 1; i <= n; ++i) | ||
{ | ||
for (int j = 1; j <= n; ++j) | ||
{ | ||
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); | ||
} | ||
} | ||
} |
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.
P3. 모듈화를 하면 좋을 것 같습니다.
|
||
for (int i = 1; i <= n; ++i) | ||
{ | ||
int cnt = 0; | ||
|
||
for (int j = 1; j <= n; ++j) | ||
{ | ||
if (dist[i][j] != INF || dist[j][i] != INF) { | ||
cnt++; | ||
} | ||
} | ||
|
||
if (cnt == n - 1) ans++; | ||
} | ||
|
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.
P3. 여기도요! 잘 푸셨네요~
###과제제출
기존제출:
15685.cpp
1238.cpp
2458.cpp