DIFF.BLOG
New
Following
Discover
Jobs
More
Suggest a blog
Upvotes plugin
Report bug
Contact
About
Sign up  
52.N皇后II
1
·
·
March 21, 2023, 12:39 p.m.
Summary
52.N 皇后 II题目描述:给一个整数 n ,返回解决方案的个数。数据范围: 1\le n\le 9 题解:经典八皇后,注意打标记。打标记使用位运算,两个对角线一个是坐标和,一个是坐标差。记得把负的搞成正的。代码:12345678910111213141516171819202122232425262728293031323334353637383940class Solution{public: const static int maxn = 1e5 + 10; const static int maxm = 1e5 + 10; const static int INF = 0x3f3f3f3f; int ans = 0; void dfs(int step, int& n, vector<int> &vis) { if (step == n) { ans++; return; } // step 行,i 列 for (int i =...
Read full post on www.luobuyu.ml →
Submit
AUTHOR
RECENT POSTS FROM THE AUTHOR