Skip to content

Commit

Permalink
2024-05-03 20:30:14
Browse files Browse the repository at this point in the history
Affected files:
.obsidian/workspace.json
src/content/blog/boj-15666-N과-M-(12).md
  • Loading branch information
gyunseo committed May 3, 2024
1 parent 9cb39a0 commit f734bff
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 7 deletions.
32 changes: 25 additions & 7 deletions .obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
}
}
]
},
{
"id": "eb395fb0544b127a",
"type": "tabs",
"children": [
{
"id": "f9bf8e36633db0aa",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "src/content/blog/boj-15666-N과-M-(12).md",
"mode": "source",
"source": false
}
}
}
]
}
],
"direction": "vertical"
Expand Down Expand Up @@ -85,7 +103,7 @@
"state": {
"type": "backlink",
"state": {
"file": "src/content/blog/boj-1699-제곱수의-합.md",
"file": "src/content/blog/boj-15666-N과-M-(12).md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand All @@ -102,7 +120,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "src/content/blog/boj-1699-제곱수의-합.md",
"file": "src/content/blog/boj-15666-N과-M-(12).md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
Expand All @@ -125,7 +143,7 @@
"state": {
"type": "outline",
"state": {
"file": "src/content/blog/boj-1699-제곱수의-합.md"
"file": "src/content/blog/boj-15666-N과-M-(12).md"
}
}
}
Expand All @@ -148,10 +166,11 @@
"table-editor-obsidian:Advanced Tables Toolbar": false
}
},
"active": "b8e26a343e35175e",
"active": "f9bf8e36633db0aa",
"lastOpenFiles": [
"src/content/blog/boj-11725-트리의-부모-찾기.md",
"src/content/blog/boj-1699-제곱수의-합.md",
"src/content/blog/boj-15666-N과-M-(12).md",
"src/content/blog/boj-11725-트리의-부모-찾기.md",
"src/content/blog/computer-science-qna.md",
"src/content/blog/boj-1026-보물.md",
"src/content/blog/boj-15663-N과-M-(9).md",
Expand Down Expand Up @@ -194,7 +213,6 @@
"src/assets/template/obsidian-template.md",
"src/content/blog/ubuntu-partition.md",
"src/content/blog/update-markdown-AST-node-url-value.md",
"src/content/blog/uninstall-wsl-completely-on-windows.md",
"src/content/blog/wooteco-2nd-thoughts.md"
"src/content/blog/uninstall-wsl-completely-on-windows.md"
]
}
61 changes: 61 additions & 0 deletions src/content/blog/boj-15666-N과-M-(12).md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
author: Gyunseo Lee
title: "BOJ 백준 15666: N과 M (12)"
pubDatetime: 2024-05-03T20:28:00+09:00
modDatetime: 2024-05-03T20:28:00+09:00
featured: false
draft: false
tags:
- PS
- Algorithms
- BOJ
- DFS
- Backtracking
- 실랜디
description: "\b백준 15666: N과 M (12) 풀이 과정"
ogImage: ""
---

## Table of contents

## 들어가며

이 문제는 전형적인 N과 M 시리즈 문제입니다.
문제의 조건을 잘 읽고, DFS와 Backtracking으로 구현하면 돼요...

## AC 받은 Python 코드

```python
import sys

input = sys.stdin.readline


def dfs(cur_len, cur_idx):
# base condition 1
if cur_len == M:
setSeqs.add(tuple(seq))
return

for i in range(cur_idx, lenNums):
seq.append(nums[i])
dfs(cur_len + 1, i)
seq.pop()


if __name__ == "__main__":
N, M = map(int, input().rstrip().split())
nums = [*sorted(map(int, input().rstrip().split()))]
seq = []
lenNums = len(nums)
setSeqs = set()
# print(nums)
for i in range(lenNums):
seq.append(nums[i])
dfs(1, i)
seq.pop()

for s in sorted(setSeqs):
print(" ".join(map(str, s)))

```

0 comments on commit f734bff

Please sign in to comment.