Skip to content

[동적 계획법] 10월 1일 #9

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[동적 계획법] 10월 1일 #9

wants to merge 1 commit into from

Conversation

sua005
Copy link
Collaborator

@sua005 sua005 commented Oct 1, 2024

인적사항

이름: 조수아
학번: 2371060

과제 제출

기존 제출: 2579, 11053, 20923

### 인적사항
이름: 조수아
학번: 2371060

### 과제 제출
기존 제출: 2579, 11053, 20923
Copy link

@flowing1ife flowing1ife left a comment

Choose a reason for hiding this comment

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

[동적계획법 코드리뷰 완료]
2579(P2)


코드 리뷰 완료하였습니다 !
주석이 있어서 코드 리뷰하는데 도움이 되었습니다 ㅎㅎ
몇 가지 사소한 코멘트 남겼으니 확인해주세요 😊

Comment on lines +6 to +7
int stepScores[MAX]; //각 계단의 점수
int maxScores[MAX]; //각 계단까지의 최대 점수를 저장하는 배열

Choose a reason for hiding this comment

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

P2

벡터 선언시에 n개 또는 n+1개만큼만 선언해준다면 메모리 측면에서 더욱 효율적인 코드가 될 것 같습니다 !



//최대 점수를 계산하는 함수
void calculateMaxScore() {

Choose a reason for hiding this comment

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

함수 따로 빼둔 거 너무 좋습니다 !

Copy link

@ruruisryu ruruisryu left a comment

Choose a reason for hiding this comment

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

11053, 20923 두 문제 너무 잘 풀어주셨습니다! 사소한 코멘트 남겨드렸으니 참고해주시면 감사할 것 같아요~ 수고하셨습니다!!

Comment on lines +9 to +11
int getMax(int a, int b) { //두 수 중 더 큰 값을 반환하는 함수
return (a > b) ? a : b;
}

Choose a reason for hiding this comment

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

최대값을 반환하는 함수는 C++에 구현되어 있는 함수를 써주시면 좋을 것 같아요!

Comment on lines +7 to +8
deque<int> doGround; //도도의 카드
deque<int> suGround; //수연의 카드

Choose a reason for hiding this comment

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

deque 자료구조를 적절히 잘 사용해주셨네요!

}

string winner = ""; //승자
playGame(dodo, suyeon, m, winner);

Choose a reason for hiding this comment

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

함수화 좋습니다!

Comment on lines +34 to +53
if (!doGround.empty() && !suGround.empty() && doGround.back() + suGround.back() == 5) {
while (!doGround.empty()) {
suyeon.push_front(doGround.front());
doGround.pop_front();
}
while (!suGround.empty()) {
suyeon.push_front(suGround.front());
suGround.pop_front();
}
}
else if ((!doGround.empty() && doGround.back() == 5) || (!suGround.empty() && suGround.back() == 5)) {
while (!suGround.empty()) {
dodo.push_front(suGround.front());
suGround.pop_front();
}
while (!doGround.empty()) {
dodo.push_front(doGround.front());
doGround.pop_front();
}
}

Choose a reason for hiding this comment

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

비슷한 행위를 하는 코드가 반복적으로 쓰여져 있는 것을 확인할 수 있네요. 함수로 따로 뺴주시면 좋을 것 같아요!

Comment on lines +16 to +22
if (isDodoTurn) {
doGround.push_back(dodo.back());
dodo.pop_back();
} else {
suGround.push_back(suyeon.back());
suyeon.pop_back();
}

Choose a reason for hiding this comment

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

비슷한 행위를 하는 코드가 반복적으로 쓰여져 있는 것을 확인할 수 있네요. 함수로 따로 뺴주시면 좋을 것 같아요!

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.

3 participants