-
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
[동적계획법] 10월 4일 #8
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "\uB3D9\uC801\uACC4\uD68D\uBC95"
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.
p1. 전반적으로 잘 풀어주셨어요!! 3190만 수정한 후, 저 다시 리뷰어로 호출해주세요! 수고하셨습니다~!
int min(int a, int b, int c){ | ||
return b > a ? c > a ? a : c : c > b ? b : c; | ||
} |
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.
p2. 삼항연산자는 가독성이 안 좋아서 최대한 피하는 게 좋아요! min 함수 2개 쓰거나, 반복문 활용해서 작성해주시면 좋을 것 같아요!
if(i+counsel[i].d < n+1) // 상담 마지막 날 다음 날 dp가 있으면 | ||
dp[i] = max(dp[i+counsel[i].d]+counsel[i].m, dp[i+1]); | ||
else // 상담 마지막 날 다음 날 dp가 없으면 | ||
dp[i] = max(counsel[i].m, dp[i+1]); |
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.
p2. dp 크기를 늘리면 한 줄로 합칠 수 있을 것 같아요!
int find(vector<vector<int>> dp, vector<vector<int>> cost, int n){ | ||
|
||
int ans [3]; | ||
for(int i=0; i<3; i++){ |
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.
p2. 첫 번째 집을 어디로 고정할지를 main에서 정하고, 함수로 보내주면 더 간결하게 작성할 수 있을 것 같아요!
while(!su_gr.empty()){ | ||
dodo.push_back(su_gr.back()); | ||
su_gr.pop_back(); | ||
} | ||
while(!do_gr.empty()){ | ||
dodo.push_back(do_gr.back()); | ||
do_gr.pop_back(); | ||
} |
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.
p2. 어느 덱으로 넣는지와, 어느 그라운드에서 가져오는지 보내주면 함수화 해봐도 좋을 것 같아요~!
char changeDir(char from, char to){ | ||
if(from == 'E'){ | ||
if(to == 'L') | ||
return 'N'; | ||
else | ||
return 'S'; | ||
} | ||
else if(from == 'W'){ | ||
if(to == 'L') | ||
return 'S'; | ||
else | ||
return 'N'; | ||
} | ||
else if(from == 'S'){ | ||
if(to == 'L') | ||
return 'E'; | ||
else | ||
return 'W'; | ||
} | ||
else{ | ||
if(to == 'L') | ||
return 'W'; | ||
else | ||
return 'E'; | ||
} | ||
} |
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.
p1. 방향 관련 배열을 사용하면 더 간편하게 작성할 수 있어요!! 예를 들어 좌표로 표현했을 때, 위로 가는 건 (-1,0)을 현재 좌표에 더해주는 거고, 왼쪽으로 가는 건 (0, -1)을 더해주는 거죠! 이런 식의 상,하,좌,우 변화값을 저장한 배열을 만들어서 관리하면 훨씬 좋아요! 한 번 수정해볼까요!!
No description provided.