-
Notifications
You must be signed in to change notification settings - Fork 8
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주차 과제 제출합니다. #18
base: main
Are you sure you want to change the base?
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.
이번 문제가 꽤 어려웠죠? 도움되시라고 간단하게 몇 개 코멘트 남긴 것도 있고, 개인적으로 궁금해서 코멘트 남긴 것도 존재합니다. 어려운 만큼 열심히 고민하시다보면 실력도 늘게 될 거예요.
2주 정도 남았네요. 남은 시간 화이팅입니다 🔥
void dfs(int cnt, int idx) { //������ ��� ��, ���� ��� | ||
if (cnt >= result) return; //���� ����� ������ ��� ���� ����� �ʿ��� ��� return | ||
if (cnt > 0) { | ||
bool solved[11] = { false, }; |
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.
,
없어도 모두 초기화됩니다
bool solved[11] = { false, }; | |
bool solved[11] = { false }; |
for (int i = 0; i < cnt; i++) { | ||
int cidx = team[i]; | ||
//���� ����� Ǯ �� �ִ� ��� �˻� | ||
for (int j = 0; j < can_solve[cidx].size(); j++) | ||
solved[can_solve[cidx][j]] = true; | ||
} | ||
bool avail = true; | ||
for (int i = 1; i <= problem; i++) { | ||
if (!solved[i]) { | ||
avail = false; | ||
break; | ||
} | ||
} | ||
//��� ����� Ǯ �� �ִٸ� �ּ� ��� ���� | ||
if (avail) | ||
result = min(result, cnt); | ||
} |
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.
Challenging 🆙
정말 놀랍게도 이 작업을 안할 수 있는 방법이 존재합니다. 하지만 지금 이 방법을 생각해내기엔 어려울 수 있겠네요
can_solve[i].push_back(num); | ||
} | ||
} | ||
dfs(0, 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.
소희님에게 이 문제가 어떤 부분에서 코드 작성이 어려웠는지 궁금합니다.
어디서 막히셨는지 한 번 설명해주시면 감사하겠습니다!
if (result == 11) result = -1; | ||
cout << result; | ||
return 0; |
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.
삼항연산자 이용하는 방법도 존재합니다.
if (result == 11) result = -1; | |
cout << result; | |
return 0; | |
cout << (result==11 ? -1 : result); |
{ | ||
cout << blue.at(i) << " "; | ||
} | ||
cout << endl << white.size() << endl; |
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.
endl
상당히 느리니까 주의하세요~
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.
'\n' 쓰기 힘들거나 귀찮을 때
#define endl '\n'
해놓으면 편리합니다.
if (it1 == blue.end()&&sum==0) { | ||
blue.push_back(i); | ||
sum++; | ||
} | ||
if (it2 == white.end()&&sum==0) { | ||
white.push_back(i); | ||
sum++; | ||
} | ||
if(sum==0) | ||
blue.push_back(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.
싫어하는 사람이 없는 사람이 일부 존재한다면 어떻게 될까요?
if (white.size() == 0) { | ||
blue.erase(blue.begin() + 1); | ||
white.push_back(1); | ||
}if (blue.size() == 0) { | ||
white.erase(white.begin() + 1); | ||
blue.push_back(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.
필요한가요?
계속 생각해보고 있는데 너무 어렵네요ㅠㅠ