96631 백준(BOJ) 9663 N-Queen(Python) 백트래킹 문제. 각 행마다 퀸을 하나씩 배치하는데, 이때 이전 행에 배치한 퀸의 열 번호를 토대로 현재 위치에 퀸을 배치할 수 있는 지를 판단한다. 코드는 다음과 같다. # -*- coding: utf-8 -*- import sys from collections import deque import heapq import copy from itertools import combinations import bisect #input=sys.stdin.readline #sys.setrecursionlimit(100000000) n=int(input()) L=[0]*n ans=0 def func2(k): for i in range(k): if L[k]==L[i] or abs(L[k]-L[i])==k-i: retu.. 2022. 7. 22. 이전 1 다음