Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions froglike6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
| 3μ°¨μ‹œ | 2025.03.24 | μ •μˆ˜ | [ν”Όλ³΄λ‚˜μΉ˜ μˆ˜μ™€ μ΅œλŒ€κ³΅μ•½μˆ˜](https://www.acmicpc.net/problem/11778)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/9|
| 4μ°¨μ‹œ | 2025.03.30 | κ·Έλž˜ν”„ | [친ꡬ](https://www.acmicpc.net/problem/1058)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/16|
| 5μ°¨μ‹œ | 2025.04.01 | μ •μˆ˜ | [개ꡬ리](https://www.acmicpc.net/problem/25333)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/17|
| 6μ°¨μ‹œ | 2025.04.07 | λ°±νŠΈλž˜ν‚Ή| [N-Queen](https://www.acmicpc.net/problem/9663)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/24|
---
17 changes: 17 additions & 0 deletions froglike6/backtracking/9663.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def dfs(row, cols, diag1, diag2):
global count
if row == n:
count += 1
return
available_positions = (~(cols | diag1 | diag2)) & ((1 << n) - 1)
while available_positions:
position = available_positions & -available_positions
available_positions &= available_positions - 1
dfs(row + 1,
cols | position,
(diag1 | position) << 1,
(diag2 | position) >> 1)
n = int(input())
count = 0
dfs(0, 0, 0, 0)
print(count)