-
Notifications
You must be signed in to change notification settings - Fork 5
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
16-janghw0126 #66
Merged
Merged
16-janghw0126 #66
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
72e63f5
2024-02-18
janghw0126 3c1b7c4
2024-02-18
janghw0126 7179d53
2024-02-18
janghw0126 6514e5c
Update Backtracking_2.py
janghw0126 7c4bf80
Update Backtracking_3.py
janghw0126 3e85b18
Merge branch 'main' into 16-janghw0126
janghw0126 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#μμ°μ Nκ³Ό Mμ μ λ ₯λ°λλ€. | ||
N, M = map(int, input().split()) | ||
#μ«μλ€μ μ λ ₯λ°μ 리μ€νΈμ μ μ₯νλ€. | ||
numbers = [int(x) for x in input().split()] | ||
#μ«μλ€μ μ€λ¦μ°¨μμΌλ‘ μ λ ¬νλ€. | ||
numbers.sort() | ||
|
||
def backtracking(depth): | ||
#νμ¬κΉμ§ μ νν μ«μμ κ°μκ° Mκ³Ό κ°λ€λ©΄ μνν λ¬Έμ΄λ€. | ||
if depth == M: | ||
#λ°μ€μ μ μ₯λ μ«μλ€μ λ¬Έμμ΄λ‘ λ³ννμ¬ κ³΅λ°±μ κΈ°μ€μΌλ‘ κ²°ν©νμ¬ μΆλ ₯νλ€. | ||
print(' '.join(map(str,box))) | ||
return | ||
#0λΆν° N-1κΉμ§μ μΈλ±μ€μ λν΄ λ°λ³΅νλ€. | ||
for i in range(N): | ||
#μ΄λ―Έ μ νλ μ«μλΌλ©΄ 건λλ΄λ€. | ||
if numbers[i] in box: | ||
continue | ||
#μ«μλ₯Ό λ°μ€μ μΆκ°νλ€. | ||
box.append(numbers[i]) | ||
#λ€μ μλ¦Ώμμ μ«μλ₯Ό μ ννκΈ° μν΄ μ¬κ·μ μΌλ‘ backtracking ν¨μλ₯Ό νΈμΆνλ€. | ||
backtracking(depth + 1) | ||
#ν¨μ νΈμΆ νμλ ν΄λΉ μλ¦Ώμμμμ μ νμ΄ λλ¬μΌλ―λ‘, λ°μ€μμ λ§μ§λ§μ μΆκ°λ μ«μλ₯Ό μ κ±°νλ€. | ||
box.pop() | ||
#μ νν μ«μλ€μ μ μ₯ν 리μ€νΈλ₯Ό μ μΈνλ€. | ||
box = [] | ||
#λ°±νΈλνΉ ν¨μλ₯Ό νΈμΆνμ¬ λ¬Έμ λ₯Ό ν΄κ²°νλ€. | ||
backtracking(0) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
μ λ κ°μ λ°©λ²μΌλ‘ νμμλ€μ γ γ
μ΄λ κ² λ¦¬μ€νΈ μμμ λ°λ‘ μ κ·Όν΄μ μ«μλ₯Ό μ μ₯νκ³ μΆλ ₯μ ν μλ μμ΅λλ€ !
μ¬ν μ€λΉλ‘ λ°μμ ¨μν λ° μ μ±μ€λ¬μ΄ PR λ¨κ²¨μ£ΌμλλΌ κ³ μνμ ¨μ΅λλ€ !! βοΈπ