Skip to content

[동적계획법] 10월 4일#8

Open
aqswa wants to merge 1 commit intomainfrom
동적계획법

Hidden character warning

The head ref may contain hidden characters: "\ub3d9\uc801\uacc4\ud68d\ubc95"
Open

[동적계획법] 10월 4일#8
aqswa wants to merge 1 commit intomainfrom
동적계획법

Conversation

@aqswa
Copy link
Collaborator

@aqswa aqswa commented Oct 3, 2021

No description provided.

Copy link

@bsa0322 bsa0322 left a comment

Choose a reason for hiding this comment

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

p1. 전반적으로 잘 풀어주셨어요!! 3190만 수정한 후, 저 다시 리뷰어로 호출해주세요! 수고하셨습니다~!

Comment on lines +7 to +9
int min(int a, int b, int c){
return b > a ? c > a ? a : c : c > b ? b : c;
}
Copy link

Choose a reason for hiding this comment

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

p2. 삼항연산자는 가독성이 안 좋아서 최대한 피하는 게 좋아요! min 함수 2개 쓰거나, 반복문 활용해서 작성해주시면 좋을 것 같아요!

Comment on lines +22 to +25
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]);
Copy link

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++){
Copy link

Choose a reason for hiding this comment

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

p2. 첫 번째 집을 어디로 고정할지를 main에서 정하고, 함수로 보내주면 더 간결하게 작성할 수 있을 것 같아요!

Comment on lines +36 to +43
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();
}
Copy link

Choose a reason for hiding this comment

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

p2. 어느 덱으로 넣는지와, 어느 그라운드에서 가져오는지 보내주면 함수화 해봐도 좋을 것 같아요~!

Comment on lines +20 to +45
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';
}
}
Copy link

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)을 더해주는 거죠! 이런 식의 상,하,좌,우 변화값을 저장한 배열을 만들어서 관리하면 훨씬 좋아요! 한 번 수정해볼까요!!

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