vector<bool>col(n,0),dg(n<<1,0);
时间: 2024-06-04 15:11:56 浏览: 17
This line of code creates two vectors, col and dg, with initial size n and n*2 respectively.
The first vector, col, is used to mark which columns of the chessboard are currently occupied by queens. It is initialized with all elements set to false (0), indicating that none of the columns are occupied.
The second vector, dg, is used to mark which diagonals of the chessboard are currently occupied by queens. Since there are 2*n-1 diagonals in a n*n chessboard, we need a vector of size n*2 to represent them. It is also initialized with all elements set to false (0), indicating that none of the diagonals are occupied.
Together, these two vectors are used to keep track of which positions on the chessboard are currently occupied by queens, which is essential for the backtracking algorithm to work properly.
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)