摘要: /*dfs,关键:检查皇后会发生攻击的状态。两种方法:(第二种,速度更快) (1)voidSolve(introw,intcolUsed); 常规办法,判断状态是否非法的方法:列上通过位运算;左斜、右斜通过遍历。 (2)voidSolveBitOperation(unsignedcol,unsig... 阅读全文
posted @ 2015-12-04 18:45 JmingS 阅读(248) 评论(0) 推荐(0) 编辑
摘要: /*注意: 输入输出采用scanf、printf,防止TLE。 两种实现方法: (1)voidSolve(intnumPos,intisUsed);//dfs (2)voidSolveWithSTL(); C++STL自带函数,可生成全排列 next_permutation( ), ... 阅读全文
posted @ 2015-12-04 15:13 JmingS 阅读(197) 评论(0) 推荐(0) 编辑
摘要: /*dfs,需要注意输入的测试数据的格式。*/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #inc... 阅读全文
posted @ 2015-12-04 13:06 JmingS 阅读(496) 评论(0) 推荐(0) 编辑
摘要: /*dfs即可AC。注意: 在清澄oj(http://www.tsinsen.com/A1126)评测时,测试数据中应该有非小写英文字母开头的字符串。 codevs中的测试数据应该都是小写英文字母开头的字符串。 所以注意数据结构的设计。*/ 1 #include 2 #include 3 #in... 阅读全文
posted @ 2015-12-04 12:09 JmingS 阅读(420) 评论(0) 推荐(0) 编辑
摘要: /*读懂题意,bfs即可AC。关键考虑好,进入队列的是谁。注意: 在实现的时候,调用std::string::operator+()和string.substr()很多次,会直接导致TLE。。 相同思路,换种实现(考虑使用string.replace()和string.find()),即可AC。*/... 阅读全文
posted @ 2015-12-04 00:54 JmingS 阅读(243) 评论(0) 推荐(0) 编辑