Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 알고리즘
- GitHub Action
- vscode
- DeepLearning
- Matplotlib
- torchserve
- Kaggle
- docker
- rnn
- Kubernetes
- GCP
- 백준
- NaverAItech
- 완전탐색
- 프로그래머스
- datascience
- github
- python
- autoencoder
- pytorch
- leetcode
- wandb
- 네이버AItech
- 코딩테스트
- GIT
- FastAPI
- FDS
- PytorchLightning
- NLP
- pep8
Archives
- Today
- Total
Sangmun
n-queen 본문
https://www.acmicpc.net/problem/9663
def adjacent(x):
for i in range(x):
if row[x] == row[i] or abs(row[x] - row[i]) == x - i:
return False
return True
def dfs(x):
global result
if x == N:
result += 1
else:
for i in range(N):
row[x] = i
if adjacent(x):
dfs(x + 1)
N = int(input())
row = [0] * N
result = 0
dfs(0)
print(result)
'알고리즘 > 백준' 카테고리의 다른 글
백준 16953번 A -> B (0) | 2022.12.08 |
---|---|
백준 1094번 막대기 (0) | 2022.12.07 |
백준 1647번 도시분할 계획 (0) | 2022.11.20 |
백준 11779번 최소비용 구하기 2 (0) | 2022.11.20 |
백준 11758번 CCW (0) | 2022.11.10 |
Comments