Skip to content
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

[백트래킹] 9월 30일 #7

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

[백트래킹] 9월 30일 #7

wants to merge 1 commit into from

Conversation

aqswa
Copy link
Collaborator

@aqswa aqswa commented Sep 30, 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. 조합도 사용하여 문제풀이 아주 잘 해주셨어요!! 15665만 조금 수정해서 저 다시 리뷰어로 호출해주세요! 수고하셨습니다~!!

Comment on lines +17 to +24
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(num[i] && num[j])
l_total += stat[i][j];
else if(!num[i] && !num[j])
s_total += stat[i][j];
}
}
Copy link

Choose a reason for hiding this comment

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

조합으로 풀어주셨네요! 아주 좋아요~! 이 부분은 함수화를 해봐도 좋을 것 같아요! 더불어 여유가 되시면 백트래킹으로도 푸신 후, 시간을 비교해 보아도 좋을 것 같아요!

Comment on lines +13 to +16
if(cnt == m){
out.insert(temp);
return;
}
Copy link

Choose a reason for hiding this comment

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

p1. 가능한 수열을 모두 만든 후, 중복 수열을 거르는 것보다, 애초에 중복 수열이 만들어지지 않도록 탐색하는 방법이 있어요! 지금 수열의 중복이 생기는 이유는 무엇일까요? 입력으로 꼭 서로 다른 숫자가 들어오지 않고 있어요. 중복 수를 미리 처리한 후, 백트래킹을 돌려볼까요!

Comment on lines +24 to +43
if(c == '<'){
for(int i=prev+1; i<10; i++){
if(!check[i]){
check[i] = true;
name[cnt] = i;
backtracking(cnt+1, i, gl[cnt]);
check[i] = false;
}
}
}
else if(c == '>'){
for(int i=0; i<prev; i++){
if(!check[i]){
check[i] = true;
name[cnt] = i;
backtracking(cnt+1, i, gl[cnt]);
check[i] = false;
}
}
}
Copy link

Choose a reason for hiding this comment

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

오! 이 탐색법은 처음 보는데 좋네요!! 👍

더불어 이 문제는 가능한 모든 수열을 구하지 않고, 바로 최솟값과 최댓값을 구할 수 있어요! 최솟값과 최댓값이 어떤 수로 이루어지는지 생각해볼까요?

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. 15661까지 수정한 후, 저 리뷰어로 호출해주세요~~!!

Comment on lines +11 to +13
for(int i=0; i<n/2; i++){
num[i] = true;
}
Copy link

Choose a reason for hiding this comment

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

지금 이 문제는 "두 팀의 인원수는 같지 않아도 되지만, 한 명 이상이어야 한다." 이 조건으로 인해 딱 절반으로 팀을 나눠서는 안돼요! 예를 들어 총 7명이라면 팀이 (1/6) (2/5) (3/4) 로 나뉘는 모든 경우를 고려해야 해요.
현재 문제에 제출하면 '맞았습니다'가 뜨긴 하지만, 아마 문제에 테스트케이스가 부족한 것 같아요. 따라서 꼭 코드 수정 해주세요!

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