
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
History is littered with hundreds of conflicts over the future of a community, group, location or business that were "resolved" when one of the parties stepped ahead and destroyed what was there. With the original point of contention destroyed, the debates would fall to the wayside. Archive Team believes that by duplicated condemned data, the conversation and debate can continue, as well as the richness and insight gained by keeping the materials. Our projects have ranged in size from a single volunteer downloading the data to a small-but-critical site, to over 100 volunteers stepping forward to acquire terabytes of user-created data to save for future generations.
The main site for Archive Team is at archiveteam.org and contains up to the date information on various projects, manifestos, plans and walkthroughs.
This collection contains the output of many Archive Team projects, both ongoing and completed. Thanks to the generous providing of disk space by the Internet Archive, multi-terabyte datasets can be made available, as well as in use by the Wayback Machine, providing a path back to lost websites and work.
Our collection has grown to the point of having sub-collections for the type of data we acquire. If you are seeking to browse the contents of these collections, the Wayback Machine is the best first stop. Otherwise, you are free to dig into the stacks to see what you may find.
The Archive Team Panic Downloads are full pulldowns of currently extant websites, meant to serve as emergency backups for needed sites that are in danger of closing, or which will be missed dearly if suddenly lost due to hard drive crashes or server failures.
n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。
上图为 8 皇后问题的一种解法。
给定一个整数 n,返回所有不同的 n 皇后问题的解决方案。
每一种解法包含一个明确的 n 皇后问题的棋子放置方案,该方案中 'Q' 和 '.' 分别代表了皇后和空位。
示例:
提示:
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/n-queens
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
思路
其实这题虽然是 hard 问题,但是思路比较清晰,还是通过递归不断的根据上一行摆放的结果去找下一行可以摆放的位置,递归进行下去,直到最后一行得出结果。
但是这题的难点在于判断的手法比较复杂,当前一行已经落下一个皇后之后,下一行需要判断三个条件:
难点在于判断对角线上是否摆放过皇后了,其实找到规律后也不难了,看图:
对角线1:直接通过这个点的横纵坐标
rowIndex + columnIndex相加,相等的话就在同在对角线 1 上:对角线2:直接通过这个点的横纵坐标
rowIndex - columnIndex相减,相等的话就在同在对角线 2 上:所以:
columns数组记录摆放过的列下标,摆放过后直接标记为 true 即可。dia1数组记录摆放过的对角线1下标,摆放过后直接把下标rowIndex + columnIndex标记为 true 即可。dia2数组记录摆放过的对角线1下标,摆放过后直接把下标rowIndex - columnIndex标记为 true 即可。row代表每一行中皇后放置的列数,比如row[0] = 3代表第 0 行皇后放在第 3 列,以此类推。有了这几个辅助知识点,就可以开始编写递归函数了,在每一行,我们都不断的尝试一个坐标点,只要它和之前已有的结果都不冲突,那么就可以放入数组中作为下一次递归的开始值。
这样,如果递归函数顺利的来到了
rowIndex === n的情况,说明之前的条件全部满足了,一个n皇后的解就产生了。