You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importsysreadl=sys.stdin.readlineboard= [[0for_inrange(14)] for_inrange(14)]
n=int(readl())
deff(ri):
# ri >= n일 경우 1 return# ri번째 행의 모든 칸을 순회한다# 가능한 칸일 경우 퀸을 배치한다. (각 케이스)# ri+1...n번째 행까지 퀸이 공격하는 세로, 두 대각선에 대해 모두 +1한다# f(ri+1)을 호출한다# 케이스 별 f(ri+1) 값을 합하여 return 한다.ifri>=n:
return1cnt=0forciinrange(n):
ifboard[ri][ci] !=0:
continue# 퀸 배치 (ri, ci)# board[ri][ci] = 99# 열 공격forri2inrange(ri+1, n):
board[ri2][ci] +=1# 대각선1 공격i=1whileri+i<nandci+i<n:
board[ri+i][ci+i] +=1i+=1# 대각선2 공격i=1whileri+i<nand0<=ci-i:
board[ri+i][ci-i] +=1i+=1""" # debug print("next", ri+1) for row in board[:n]: for v in row[:n]: print(f"{v:4d}", end='') print() """# 하위 경우의 수 구함cnt+=f(ri+1)
# 공격 초기화# board[ri][ci] = 0forri2inrange(ri+1, n):
board[ri2][ci] -=1i=1whileri+i<nandci+i<n:
board[ri+i][ci+i] -=1i+=1i=1whileri+i<nand0<=ci-i:
board[ri+i][ci-i] -=1i+=1returncntprint(f(0))
Self-feedback
구조적 접근: 문제를 추상화하여 구조적으로 접근했는가?
O
사고력: 알고리즘을 완전히 이해했는가? (충분한 사고력을 가졌는가?)
구현력: 알고리즘을 신속, 정확하게 구현했는가?
O
The text was updated successfully, but these errors were encountered:
Problem link
https://www.acmicpc.net/problem/9663
Problem abstraction
Design(Plan) algorithm
Algorithm idea
시뮬레이션 (백트래킹, DFS)
Pseudo-code
아래 주석 참고
Validate algorithm
Impl
Self-feedback
구조적 접근: 문제를 추상화하여 구조적으로 접근했는가?
O
사고력: 알고리즘을 완전히 이해했는가? (충분한 사고력을 가졌는가?)
구현력: 알고리즘을 신속, 정확하게 구현했는가?
O
The text was updated successfully, but these errors were encountered: